@@ -282,6 +282,46 @@ TEST_CASE_METHOD(
282282 REQUIRE_THROWS_WITH (enmr.extend (add_values), matcher);
283283}
284284
285+ TEST_CASE_METHOD (
286+ CPPEnumerationFx,
287+ " CPP: Enumeration API - Var Size index_of" ,
288+ " [enumeration][index_of]" ) {
289+ std::vector<std::string> init_values = {" fred" , " wilma" };
290+ auto enmr = Enumeration::create (ctx_, enmr_name, init_values, true );
291+
292+ std::string_view val = " wilma" ;
293+
294+ REQUIRE (enmr.index_of (val).has_value () == true );
295+ REQUIRE (enmr.index_of (val).value () == 1 );
296+ }
297+
298+ TEST_CASE_METHOD (
299+ CPPEnumerationFx,
300+ " CPP: Enumeration API - Fix Size Int64 index_of" ,
301+ " [enumeration][index_of]" ) {
302+ std::vector<int64_t > init_values = {1 , 5 , 6 };
303+ auto enmr =
304+ Enumeration::create (ctx_, enmr_name, init_values, true , TILEDB_INT64);
305+ std::string_view val = " wilma" ;
306+ REQUIRE (enmr.index_of (val).has_value () == false );
307+
308+ REQUIRE (enmr.index_of <int32_t >(1 ).has_value () == false );
309+ REQUIRE (enmr.index_of <int64_t >(1 ).has_value () == true );
310+ }
311+
312+ TEST_CASE_METHOD (
313+ CPPEnumerationFx,
314+ " CPP: Enumeration API - Fix Size Float32 index_of" ,
315+ " [enumeration][index_of]" ) {
316+ std::vector<float_t > init_values = {1 , 5 , 6 , -4 };
317+ auto enmr = Enumeration::create (ctx_, enmr_name, init_values, true );
318+
319+ REQUIRE (enmr.index_of <int32_t >(-4 ).has_value () == false );
320+ REQUIRE (enmr.index_of <float_t >(-4 ).has_value () == true );
321+ REQUIRE (enmr.index_of <float_t >(-4 ).value () == 3 );
322+ REQUIRE (enmr.index_of <double_t >(-4 ).has_value () == false );
323+ }
324+
285325TEST_CASE_METHOD (
286326 CPPEnumerationFx,
287327 " CPP: Enumeration API - Dump Basic" ,
0 commit comments