Skip to content

Commit a9b5c85

Browse files
fix tests
1 parent 8935465 commit a9b5c85

2 files changed

Lines changed: 38 additions & 32 deletions

File tree

tests/stochastic/spatial/test-object-set.cpp

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,57 +42,62 @@ namespace
4242
"[TestObjectSet] - Set should not be empty after insertions" );
4343

4444
const auto& p = set.get_object( idx1 );
45-
OPENGEODE_EXCEPTION( p == geode::Point2D( { { 1.0, 1.0 } } ),
46-
"[TestObjectSet] - Wrong object value at index 1" );
45+
const auto result = geode::Point2D{ { 1.0, 1.0 } };
46+
OPENGEODE_EXCEPTION(
47+
p == result, "[TestObjectSet] - Wrong object value at index 1" );
4748
}
4849

4950
void test_update_object()
5051
{
5152
geode::ObjectSet< geode::Point2D > set;
52-
const auto idx0 = set.add_object( geode::Point2D( { { 0.0, 0.0 } } ) );
53-
const auto idx1 = set.add_object( geode::Point2D( { { 1.0, 1.0 } } ) );
53+
const auto idx0 = set.add_object( geode::Point2D{ { 0.0, 0.0 } } );
54+
const auto idx1 = set.add_object( geode::Point2D{ { 1.0, 1.0 } } );
5455

55-
set.update_object( idx1, geode::Point2D( { { 5.0, 5.0 } } ) );
56+
set.update_object( idx1, geode::Point2D{ { 5.0, 5.0 } } );
5657

5758
const auto& updated = set.get_object( idx1 );
58-
OPENGEODE_EXCEPTION( updated == geode::Point2D( { { 5.0, 5.0 } } ),
59-
"[TestObjectSet] - Object update failed" );
59+
60+
const auto new_point = geode::Point2D{ { 5.0, 5.0 } };
61+
OPENGEODE_EXCEPTION(
62+
updated == new_point, "[TestObjectSet] - Object update failed" );
6063
}
6164

6265
void test_remove_object()
6366
{
6467
geode::ObjectSet< geode::Point2D > set;
65-
set.add_object( geode::Point2D( { { 0.0, 0.0 } } ) );
66-
set.add_object( geode::Point2D( { { 1.0, 1.0 } } ) );
67-
set.add_object( geode::Point2D( { { 2.0, 2.0 } } ) );
68+
set.add_object( geode::Point2D{ { 0.0, 0.0 } } );
69+
set.add_object( geode::Point2D{ { 1.0, 1.0 } } );
70+
set.add_object( geode::Point2D{ { 2.0, 2.0 } } );
6871

6972
set.remove_object( 1 );
7073

7174
OPENGEODE_EXCEPTION( set.size() == 2,
7275
"[TestObjectSet] - Set size should be 2 after removal" );
7376

7477
const auto& last = set.get_object( 1 );
75-
OPENGEODE_EXCEPTION( last == geode::Point2D( { { 2.0, 2.0 } } ),
78+
const auto result = geode::Point2D{ { 2.0, 2.0 } };
79+
OPENGEODE_EXCEPTION( last == result,
7680
"[TestObjectSet] - Remaining objects not shifted properly after "
7781
"removal" );
7882
}
7983

8084
void test_const_access()
8185
{
8286
geode::ObjectSet< geode::Point2D > set;
83-
set.add_object( geode::Point2D( { { 10.0, 10.0 } } ) );
87+
set.add_object( geode::Point2D{ { 10.0, 10.0 } } );
8488

8589
const auto& const_set = set;
8690
const auto& p = const_set.get_object( 0 );
87-
OPENGEODE_EXCEPTION( p == geode::Point2D( { { 10.0, 10.0 } } ),
88-
"[TestObjectSet] - Const access mismatch" );
91+
const auto result = geode::Point2D{ { 10.0, 10.0 } };
92+
OPENGEODE_EXCEPTION( p == result ),
93+
"[TestObjectSet] - Const access mismatch";
8994
}
9095

9196
void test_string_representation()
9297
{
9398
geode::ObjectSet< geode::Point2D > set;
94-
set.add_object( geode::Point2D( { { 0.0, 0.0 } } ) );
95-
set.add_object( geode::Point2D( { { 1.0, 1.0 } } ) );
99+
set.add_object( geode::Point2D{ { 0.0, 0.0 } } );
100+
set.add_object( geode::Point2D{ { 1.0, 1.0 } } );
96101

97102
const auto desc = set.string();
98103
OPENGEODE_EXCEPTION( desc.find( "2 objects" ) != std::string::npos,

tests/stochastic/spatial/test-object-sets.cpp

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@ namespace
2929

3030
void test_add_sets_and_objects()
3131
{
32-
ObjectSets< Point2D > sets;
32+
ObjectSets< geode::Point2D > sets;
3333
const auto set_id1 = sets.add_set();
3434
const auto set_id2 = sets.add_set();
3535

3636
OPENGEODE_EXCEPTION(
3737
sets.nb_sets() == 2, "[TestObjectSets] - Expected 2 sets" );
3838

3939
const auto obj_a =
40-
sets.add_object( geode::Point2D( { { 0.0, 0.0 } } ), set_id1 );
40+
sets.add_object( geode::Point2D{ { 0.0, 0.0 } }, set_id1 );
4141
const auto obj_b =
42-
sets.add_object( geode::Point2D( { { 1.0, 1.0 } } ), set_id1 );
42+
sets.add_object( geode::Point2D{ { 1.0, 1.0 } }, set_id1 );
4343
const auto obj_c =
44-
sets.add_object( geode::Point2D( { { 5.0, 5.0 } } ), set_id2 );
44+
sets.add_object( geode::Point2D{ { 5.0, 5.0 } }, set_id2 );
4545

4646
OPENGEODE_EXCEPTION( sets.nb_objects_in_set( set_id1 ) == 2,
4747
"[TestObjectSets] - Set 1 should have 2 objects" );
@@ -51,21 +51,22 @@ namespace
5151
"[TestObjectSets] - Total object count mismatch" );
5252

5353
const auto& point = sets.get_object( obj_b );
54-
OPENGEODE_EXCEPTION( point == Point2D( { { 1.0, 1.0 } } ),
54+
const auto result = geode::Point2D{ { 1.0, 1.0 } };
55+
OPENGEODE_EXCEPTION( point == result,
5556
"[TestObjectSets] - Wrong object value retrieved" );
5657
}
5758

5859
void test_neighbors_by_object_id()
5960
{
60-
ObjectSets< Point2D > sets;
61+
ObjectSets< geode::Point2D > sets;
6162
const auto set_id = sets.add_set();
6263

6364
const auto obj0 =
64-
sets.add_object( geode::Point2D( { { 0.0, 0.0 } } ), set_id );
65+
sets.add_object( geode::Point2D{ { 0.0, 0.0 } }, set_id );
6566
const auto obj1 =
66-
sets.add_object( geode::Point2D( { { 1.0, 0.0 } } ), set_id );
67+
sets.add_object( geode::Point2D{ { 1.0, 0.0 } }, set_id );
6768
const auto obj2 =
68-
sets.add_object( geode::Point2D( { { 5.0, 0.0 } } ), set_id );
69+
sets.add_object( geode::Point2D{ { 5.0, 0.0 } }, set_id );
6970

7071
// Near neighbors should be within distance 2.0
7172
const auto near_neighbors = sets.neighbors( obj0, 2.0 );
@@ -82,12 +83,12 @@ namespace
8283

8384
void test_neighbors_by_object_value()
8485
{
85-
ObjectSets< Point2D > sets;
86+
ObjectSets< geode::Point2D > sets;
8687
const auto set_id = sets.add_set();
8788

88-
sets.add_object( geode::Point2D( { { 0.0, 0.0 } } ), set_id );
89-
sets.add_object( geode::Point2D( { { 1.0, 0.0 } } ), set_id );
90-
sets.add_object( geode::Point2D( { { 3.0, 0.0 } } ), set_id );
89+
sets.add_object( geode::Point2D{ { 0.0, 0.0 } }, set_id );
90+
sets.add_object( geode::Point2D{ { 1.0, 0.0 } }, set_id );
91+
sets.add_object( geode::Point2D{ { 3.0, 0.0 } }, set_id );
9192

9293
const geode::Point2D query( { { 0.5, 0.0 } } );
9394
const auto nearby = sets.neighbors( query, 1.0 );
@@ -100,10 +101,10 @@ namespace
100101

101102
void test_string_representation()
102103
{
103-
ObjectSets< Point2D > sets;
104+
ObjectSets< geode::Point2D > sets;
104105
const auto set_id = sets.add_set();
105-
sets.add_object( geode::Point2D( { { 0.0, 0.0 } } ), set_id );
106-
sets.add_object( geode::Point2D( { { 1.0, 1.0 } } ), set_id );
106+
sets.add_object( geode::Point2D{ { 0.0, 0.0 } }, set_id );
107+
sets.add_object( geode::Point2D{ { 1.0, 1.0 } }, set_id );
107108

108109
const auto desc = sets.string();
109110
OPENGEODE_EXCEPTION( desc.find( "objects" ) != std::string::npos,

0 commit comments

Comments
 (0)