From d9b13ff101555153e750ff225959d89e4932e79d Mon Sep 17 00:00:00 2001 From: Alastair Robertson Date: Tue, 21 Feb 2023 12:03:47 -0800 Subject: [PATCH] Integration tests: Test templates --- test/integration/CMakeLists.txt | 1 + test/integration/templates.toml | 75 +++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 test/integration/templates.toml diff --git a/test/integration/CMakeLists.txt b/test/integration/CMakeLists.txt index 95cb103..d1ee935 100644 --- a/test/integration/CMakeLists.txt +++ b/test/integration/CMakeLists.txt @@ -44,6 +44,7 @@ set(INTEGRATION_TEST_CONFIGS std_variant.toml std_vector.toml std_vector_del_allocator.toml + templates.toml typedefs.toml typedefed_parent.toml ) diff --git a/test/integration/templates.toml b/test/integration/templates.toml new file mode 100644 index 0000000..3552859 --- /dev/null +++ b/test/integration/templates.toml @@ -0,0 +1,75 @@ +includes = ["vector"] +definitions = ''' + template + class TemplatedClass1 { + T val; + }; + + template + class TemplatedClass2 { + TemplatedClass1 tc1; + S val2; + }; + + struct Foo { + int a; + int b; + }; + + template + struct TemplatedClassVal { + int arr[N]; + }; +''' + +[cases] + [cases.int] + param_types = ["const TemplatedClass1&"] + setup = "return {};" + expect_json = '''[{ + "typeName":"TemplatedClass1", + "staticSize":4, + "dynamicSize":0, + "members":[{ + "typeName":"int" + }]}]''' + [cases.vector] + param_types = ["const TemplatedClass1>&"] + setup = "return {};" + expect_json = '''[{ + "typeName":"TemplatedClass1 > >", + "staticSize":24, + "dynamicSize":0, + "members":[{ + "typeName":"vector >", + "staticSize":24, + "dynamicSize":0, + "length":0, + "capacity":0, + "elementStaticSize":4 + }]}]''' + [cases.two] + param_types = ["const TemplatedClass2&"] + setup = "return {};" + expect_json = '''[{ + "typeName":"TemplatedClass2", + "staticSize":12, + "dynamicSize":0, + "members":[ + {"typeName":"TemplatedClass1", "staticSize":8, "dynamicSize":0}, + {"typeName":"int", "staticSize":4, "dynamicSize":0} + ]}]''' + [cases.value] + param_types = ["const TemplatedClassVal<3>&"] + setup = "return {};" + expect_json = '''[{ + "typeName":"TemplatedClassVal<3>", + "staticSize":12, + "dynamicSize":0, + "members":[{ + "staticSize":12, + "dynamicSize":0, + "length":3, + "capacity":3, + "elementStaticSize":4 + }]}]'''