diff --git a/cpp-client/deephaven/tests/src/add_drop_test.cc b/cpp-client/deephaven/tests/src/add_drop_test.cc index 89901c09373..dbd2bce292f 100644 --- a/cpp-client/deephaven/tests/src/add_drop_test.cc +++ b/cpp-client/deephaven/tests/src/add_drop_test.cc @@ -6,7 +6,7 @@ namespace deephaven::client::tests { -TEST_CASE("Drop all columns", "[adddrop]") { +TEST_CASE("Drop some columns", "[adddrop]") { auto tm = TableMakerForTests::Create(); auto table = tm.Table(); auto t = table.Update("II = ii").Where("Ticker == `AAPL`"); diff --git a/cpp-client/deephaven/tests/src/attributes_test.cc b/cpp-client/deephaven/tests/src/attributes_test.cc index e0af4df9002..43684411a41 100644 --- a/cpp-client/deephaven/tests/src/attributes_test.cc +++ b/cpp-client/deephaven/tests/src/attributes_test.cc @@ -28,6 +28,6 @@ TEST_CASE("TableHandle Created By DoPut", "[attributes]") { CHECK(table.IsStatic()); // The columns all have the same size, so look at the source data for any one of them and get its size auto expected_size = static_cast(tm.ColumnData().ImportDate().size()); - CHECK(table.NumRows() == expected_size); + CHECK(expected_size == table.NumRows()); } } // namespace deephaven::client::tests diff --git a/cpp-client/deephaven/tests/src/join_test.cc b/cpp-client/deephaven/tests/src/join_test.cc index 0582991585a..fde79b7e481 100644 --- a/cpp-client/deephaven/tests/src/join_test.cc +++ b/cpp-client/deephaven/tests/src/join_test.cc @@ -135,8 +135,6 @@ TEST_CASE("Aj", "[join]") { TEST_CASE("Raj", "[join]") { auto tm = TableMakerForTests::Create(); - auto q = arrow::timestamp(arrow::TimeUnit::NANO, "UTC"); - TableHandle trades; { std::vector ticker_data = {"AAPL", "AAPL", "AAPL", "IBM", "IBM"}; @@ -206,15 +204,6 @@ TEST_CASE("Raj", "[join]") { std::vector> bid_size_data = {10, {}, {}, 5, 13}; std::vector> ask_data = {2.5, {}, {}, 105, 110}; std::vector> ask_size_data = {83, {}, {}, 47, 15}; - TableMaker table_maker; - table_maker.AddColumn("Ticker", ticker_data); - table_maker.AddColumn("Timestamp", timestamp_data); - table_maker.AddColumn("Price", price_data); - table_maker.AddColumn("Size", size_data); - table_maker.AddColumn("Bid", bid_data); - table_maker.AddColumn("BidSize", bid_size_data); - table_maker.AddColumn("Ask", ask_data); - table_maker.AddColumn("AskSize", ask_size_data); CompareTable( result, diff --git a/cpp-client/deephaven/tests/src/sort_test.cc b/cpp-client/deephaven/tests/src/sort_test.cc index 2c94ca72805..1bcf318c291 100644 --- a/cpp-client/deephaven/tests/src/sort_test.cc +++ b/cpp-client/deephaven/tests/src/sort_test.cc @@ -54,12 +54,6 @@ TEST_CASE("Sort temp Table", "[sort]") { auto sorted = temp_table.Sort(SortPair::Descending("IntValue3"), SortPair::Ascending("IntValue2")); - std::vector import_date_data = {"2017-11-01", "2017-11-01", "2017-11-01"}; - std::vector ticker_data = {"AAPL", "AAPL", "AAPL"}; - std::vector open_data = {22.1, 26.8, 31.5}; - std::vector close_data = {23.5, 24.2, 26.7}; - std::vector vol_data = {100000, 250000, 19000}; - std::vector sid0{8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7}; std::vector sid1{4, 4, 5, 5, 6, 6, 7, 7, 0, 0, 1, 1, 2, 2, 3, 3}; std::vector sid2{2, 2, 2, 2, 3, 3, 3, 3, 0, 0, 0, 0, 1, 1, 1, 1}; diff --git a/cpp-client/deephaven/tests/src/update_by_test.cc b/cpp-client/deephaven/tests/src/update_by_test.cc index e371a96f4da..79a9fd32738 100644 --- a/cpp-client/deephaven/tests/src/update_by_test.cc +++ b/cpp-client/deephaven/tests/src/update_by_test.cc @@ -154,7 +154,6 @@ TEST_CASE("UpdateBy: Multiple Ops", "[update_by]") { namespace { std::vector MakeTables(const Client &client) { - std::vector result; auto tm = client.GetManager(); auto static_table = MakeRandomTable(client).Update("Timestamp=now()"); auto ticking_table = tm.TimeTable(std::chrono::seconds(1)) diff --git a/cpp-client/deephaven/tests/src/validation_test.cc b/cpp-client/deephaven/tests/src/validation_test.cc index dcc07d12ede..2b2062db121 100644 --- a/cpp-client/deephaven/tests/src/validation_test.cc +++ b/cpp-client/deephaven/tests/src/validation_test.cc @@ -15,8 +15,6 @@ using deephaven::dhcore::utility::separatedList; namespace deephaven::client::tests { namespace { -void TestWheres(const TableHandleManager &scope); -void TestSelects(const TableHandleManager &scope); void TestWheresHelper(std::string_view what, const TableHandle &table, const std::vector &bad_wheres, const std::vector &good_wheres); @@ -26,19 +24,26 @@ void TestSelectsHelper(std::string_view what, const TableHandle &table, } // namespace TEST_CASE("Validate selects", "[validation]") { - auto tm = TableMakerForTests::Create(); - auto table = tm.Table(); - TestSelects(tm.Client().GetManager()); -} + std::vector> bad_selects = { + { "X = 3)" }, + { "S = `hello`", "T = java.util.regex.Pattern.quote(S)" }, // Pattern.quote not on whitelist + { "X = Math.min(3, 4)" } // Math.min not on whitelist + }; + std::vector> good_selects = { + {"X = 3"}, + {"S = `hello`", "T = S.length()"}, // instance methods of String ok + {"X = min(3, 4)"}, // "builtin" from GroovyStaticImports + {"X = isFinite(3)"}, // another builtin from GroovyStaticImports + }; -TEST_CASE("Validate wheres", "[validation]") { auto tm = TableMakerForTests::Create(); - auto table = tm.Table(); - TestWheres(tm.Client().GetManager()); + auto thm = tm.Client().GetManager(); + auto static_table = thm.EmptyTable(10) + .Update("X = 12", "S = `hello`"); + TestSelectsHelper("static Table", static_table, bad_selects, good_selects); } -namespace { -void TestWheres(const TableHandleManager &scope) { +TEST_CASE("Validate wheres", "[validation]") { std::vector bad_wheres = { "X > 3)", // syntax error "S = new String(`hello`)", // new not allowed @@ -55,11 +60,14 @@ void TestWheres(const TableHandleManager &scope) { "X in 3, 4, 5", }; - auto static_table = scope.EmptyTable(10) + auto tm = TableMakerForTests::Create(); + auto thm = tm.Client().GetManager(); + auto static_table = thm.EmptyTable(10) .Update("X = 12", "S = `hello`"); TestWheresHelper("static Table", static_table, bad_wheres, good_wheres); } +namespace { void TestWheresHelper(std::string_view what, const TableHandle &table, const std::vector &bad_wheres, const std::vector &good_wheres) { @@ -81,37 +89,18 @@ void TestWheresHelper(std::string_view what, const TableHandle &table, } } -void TestSelects(const TableHandleManager &scope) { - std::vector> bad_selects = { - { "X = 3)" }, - { "S = `hello`", "T = java.util.regex.Pattern.quote(S)" }, // Pattern.quote not on whitelist - { "X = Math.min(3, 4)" } // Math.min not on whitelist - }; - std::vector> good_selects = { - {"X = 3"}, - {"S = `hello`", "T = S.length()"}, // instance methods of String ok - {"X = min(3, 4)"}, // "builtin" from GroovyStaticImports - {"X = isFinite(3)"}, // another builtin from GroovyStaticImports - }; - auto static_table = scope.EmptyTable(10) - .Update("X = 12", "S = `hello`"); - TestSelectsHelper("static Table", static_table, bad_selects, good_selects); -} - void TestSelectsHelper(std::string_view what, const TableHandle &table, const std::vector> &bad_selects, const std::vector> &good_selects) { for (const auto &bs : bad_selects) { - SimpleOstringstream selection; - selection << separatedList(bs.begin(), bs.end()); try { (void)table.Select(bs); } catch (const std::exception &e) { - fmt::print(std::cerr, "{}: {}: Failed as expected with: {}\n", what, selection.str(), e.what()); + fmt::print(std::cerr, "{}: {}: Failed as expected with: {}\n", what, bs, e.what()); continue; } throw std::runtime_error(fmt::format("{}: {}: Expected to fail, but succeeded", - what, selection.str())); + what, bs)); } for (const auto &gs : good_selects) {