55 *
66 * The MIT License
77 *
8- * @copyright Copyright (c) 2023 TileDB Inc.
8+ * @copyright Copyright (c) 2024 TileDB Inc.
99 *
1010 * Permission is hereby granted, free of charge, to any person obtaining a copy
1111 * of this software and associated documentation files (the "Software"), to deal
2727 *
2828 * @section DESCRIPTION
2929 *
30- * Tests tiledb_array_schema_load* functions via a REST server .
30+ * Tests tiledb_array_schema_load* functions across VFS backends and REST .
3131 */
3232
3333#include " test/support/src/vfs_helpers.h"
4040
4141using namespace tiledb ;
4242
43- struct RESTArraySchemaLoadFx {
44- RESTArraySchemaLoadFx ();
45- ~RESTArraySchemaLoadFx () = default ;
43+ struct ArraySchemaLoadFx {
44+ ArraySchemaLoadFx ();
45+ ~ArraySchemaLoadFx () = default ;
4646
4747 void create_array ();
48+ void check_schema (const ArraySchema& schema) const ;
4849
4950 test::VFSTestSetup vfs_test_setup_;
5051 std::string uri_;
5152 Context ctx_;
53+ ArraySchema schema_;
5254};
5355
5456TEST_CASE_METHOD (
55- RESTArraySchemaLoadFx ,
57+ ArraySchemaLoadFx ,
5658 " Simple schema load test" ,
5759 " [rest][array-schema][simple-load]" ) {
5860 create_array ();
@@ -68,10 +70,12 @@ TEST_CASE_METHOD(
6870 REQUIRE_THROWS_WITH (
6971 ArraySchemaExperimental::get_enumeration (ctx_, schema, " my_enum" ),
7072 matcher);
73+
74+ check_schema (schema);
7175}
7276
7377TEST_CASE_METHOD (
74- RESTArraySchemaLoadFx ,
78+ ArraySchemaLoadFx ,
7579 " Simple schema load with enumerations test" ,
7680 " [rest][array-schema][simple-load-with-enumerations]" ) {
7781 create_array ();
@@ -80,15 +84,18 @@ TEST_CASE_METHOD(
8084 ArrayExperimental::load_schema_with_enumerations (ctx_, uri_);
8185 REQUIRE_NOTHROW (
8286 ArraySchemaExperimental::get_enumeration (ctx_, schema, " my_enum" ));
87+
88+ check_schema (schema);
8389}
8490
85- RESTArraySchemaLoadFx::RESTArraySchemaLoadFx ()
91+ ArraySchemaLoadFx::ArraySchemaLoadFx ()
8692 : vfs_test_setup_()
8793 , uri_(vfs_test_setup_.array_uri(" array-schema-load-tests" ))
88- , ctx_(vfs_test_setup_.ctx()) {
94+ , ctx_(vfs_test_setup_.ctx())
95+ , schema_(ctx_, TILEDB_DENSE) {
8996}
9097
91- void RESTArraySchemaLoadFx ::create_array () {
98+ void ArraySchemaLoadFx ::create_array () {
9299 // Create a simple array for testing. This ends up with just five elements in
93100 // the array. dim is an int32_t dimension, attr1 is an enumeration with string
94101 // values and int32_t attribute values. attr2 is a float attribute.
@@ -99,24 +106,45 @@ void RESTArraySchemaLoadFx::create_array() {
99106 // dim = {1, 2, 3, 4, 5}
100107 // attr1 = {"fred", "wilma", "barney", "wilma", "fred"}
101108 // attr2 = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f}
102- ArraySchema schema (ctx_, TILEDB_DENSE);
103-
104109 auto dim = Dimension::create<int >(ctx_, " dim" , {{-100 , 100 }});
105110 auto dom = Domain (ctx_);
106111 dom.add_dimension (dim);
107- schema .set_domain (dom);
112+ schema_ .set_domain (dom);
108113
109114 // The list of string values in the attr1 enumeration
110115 std::vector<std::string> values = {" fred" , " wilma" , " barney" , " pebbles" };
111116 auto enmr = Enumeration::create (ctx_, " my_enum" , values);
112- ArraySchemaExperimental::add_enumeration (ctx_, schema , enmr);
117+ ArraySchemaExperimental::add_enumeration (ctx_, schema_ , enmr);
113118
114119 auto attr1 = Attribute::create<int >(ctx_, " attr1" );
115120 AttributeExperimental::set_enumeration_name (ctx_, attr1, " my_enum" );
116- schema .add_attribute (attr1);
121+ schema_ .add_attribute (attr1);
117122
118123 auto attr2 = Attribute::create<float >(ctx_, " attr2" );
119- schema.add_attribute (attr2);
124+ schema_.add_attribute (attr2);
125+
126+ Array::create (uri_, schema_);
127+ }
120128
121- Array::create (uri_, schema);
129+ void ArraySchemaLoadFx::check_schema (const ArraySchema& schema) const {
130+ CHECK (schema.array_type () == schema_.array_type ());
131+ CHECK (schema.attributes ().size () == schema_.attributes ().size ());
132+ for (unsigned int i = 0 ; i < schema.attribute_num (); i++) {
133+ auto a = schema_.attribute (i);
134+ auto b = schema.attribute (i);
135+ CHECK (a.cell_val_num () == b.cell_val_num ());
136+ CHECK (a.name () == b.name ());
137+ CHECK (a.type () == b.type ());
138+ CHECK (a.nullable () == b.nullable ());
139+ CHECK (
140+ AttributeExperimental::get_enumeration_name (ctx_, a) ==
141+ AttributeExperimental::get_enumeration_name (ctx_, b));
142+ }
143+ CHECK (schema.capacity () == schema_.capacity ());
144+ CHECK (schema.cell_order () == schema_.cell_order ());
145+ CHECK (schema.tile_order () == schema_.tile_order ());
146+ CHECK (schema.allows_dups () == schema_.allows_dups ());
147+ CHECK (
148+ schema.ptr ()->array_schema_ ->array_uri ().to_string () ==
149+ sm::URI (uri_).to_string ());
122150}
0 commit comments