utImporter.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. /*
  2. ---------------------------------------------------------------------------
  3. Open Asset Import Library (assimp)
  4. ---------------------------------------------------------------------------
  5. Copyright (c) 2006-2025, assimp team
  6. All rights reserved.
  7. Redistribution and use of this software in source and binary forms,
  8. with or without modification, are permitted provided that the following
  9. conditions are met:
  10. * Redistributions of source code must retain the above
  11. copyright notice, this list of conditions and the
  12. following disclaimer.
  13. * Redistributions in binary form must reproduce the above
  14. copyright notice, this list of conditions and the
  15. following disclaimer in the documentation and/or other
  16. materials provided with the distribution.
  17. * Neither the name of the assimp team, nor the names of its
  18. contributors may be used to endorse or promote products
  19. derived from this software without specific prior
  20. written permission of the assimp team.
  21. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  25. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  27. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. ---------------------------------------------------------------------------
  33. */
  34. #include "UnitTestPCH.h"
  35. #include "../../include/assimp/postprocess.h"
  36. #include "../../include/assimp/scene.h"
  37. #include "TestIOSystem.h"
  38. #include <assimp/BaseImporter.h>
  39. #include <assimp/DefaultIOSystem.h>
  40. #include <assimp/Importer.hpp>
  41. using namespace ::std;
  42. using namespace ::Assimp;
  43. class ImporterTest : public ::testing::Test {
  44. protected:
  45. void SetUp() override {
  46. pImp = new Importer();
  47. }
  48. void TearDown() override {
  49. delete pImp;
  50. }
  51. Importer *pImp;
  52. };
  53. #define InputData_BLOCK_SIZE 1310
  54. // clang-format off
  55. // test data for Importer::ReadFileFromMemory() - ./test/3DS/CameraRollAnim.3ds
  56. static unsigned char InputData_abRawBlock[1310] = {
  57. 77, 77, 30, 5, 0, 0, 2, 0, 10, 0, 0, 0, 3, 0, 0, 0, 61, 61, 91, 3, 0, 0,
  58. 62, 61, 10, 0, 0, 0, 3, 0, 0, 0, 0, 1, 10, 0, 0, 0, 0, 0,128, 63, 0, 64,
  59. 254, 2, 0, 0, 66,111,120, 48, 49, 0, 0, 65,242, 2, 0, 0, 16, 65, 64, 1, 0, 0,
  60. 26, 0,102, 74,198,193,102, 74,198,193, 0, 0, 0, 0,205,121, 55, 66,102, 74,198,193,
  61. 0, 0, 0, 0,102, 74,198,193,138,157,184, 65, 0, 0, 0, 0,205,121, 55, 66,138,157,
  62. 184, 65, 0, 0, 0, 0,102, 74,198,193,102, 74,198,193, 90,252, 26, 66,205,121, 55, 66,
  63. 102, 74,198,193, 90,252, 26, 66,102, 74,198,193,138,157,184, 65, 90,252, 26, 66,205,121,
  64. 55, 66,138,157,184, 65, 90,252, 26, 66,102, 74,198,193,102, 74,198,193, 0, 0, 0, 0,
  65. 205,121, 55, 66,102, 74,198,193, 0, 0, 0, 0,205,121, 55, 66,102, 74,198,193, 90,252,
  66. 26, 66,205,121, 55, 66,102, 74,198,193, 90,252, 26, 66,102, 74,198,193,102, 74,198,193,
  67. 90, 252, 26, 66,102, 74,198,193,102, 74,198,193, 0, 0, 0, 0,205,121, 55, 66,138,157,
  68. 184, 65, 0, 0, 0, 0,205,121, 55, 66,102, 74,198,193, 90,252, 26, 66,205,121, 55, 66,
  69. 138,157,184, 65, 0, 0, 0, 0,102, 74,198,193,138,157,184, 65, 0, 0, 0, 0,102, 74,
  70. 198,193,138,157,184, 65, 90,252, 26, 66,102, 74,198,193,138,157,184, 65, 90,252, 26, 66,
  71. 205,121, 55, 66,138,157,184, 65, 90,252, 26, 66,205,121, 55, 66,138,157,184, 65, 0, 0,
  72. 0, 0,102, 74,198,193,138,157,184, 65, 0, 0, 0, 0,102, 74,198,193,102, 74,198,193,
  73. 90,252, 26, 66,102, 74,198,193,102, 74,198,193, 90,252, 26, 66,102, 74,198,193,138,157,
  74. 184, 65, 0, 0, 0, 0, 64, 65,216, 0, 0, 0, 26, 0, 0, 0,128, 63, 0, 0, 0, 0,
  75. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128, 63, 0, 0,128, 63, 0, 0, 0, 0, 0, 0,
  76. 128, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128, 63, 0, 0, 0, 0, 0, 0, 0, 0,
  77. 0, 0,128, 63, 0, 0,128, 63, 0, 0,128, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  78. 128, 63, 0, 0, 0, 0, 0, 0,128, 63, 0, 0,128, 63, 0, 0,128, 63, 0, 0,128, 63,
  79. 0, 0, 0, 0, 0, 0,128, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128, 63, 0, 0,
  80. 0, 0, 0, 0, 0, 0, 0, 0,128, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128, 63,
  81. 0, 0, 0, 0, 0, 0,128, 63, 0, 0,128, 63, 0, 0,128, 63, 0, 0,128, 63, 0, 0,
  82. 0, 0, 0, 0,128, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  83. 0, 0,128, 63, 0, 0,128, 63, 0, 0,128, 63, 0, 0,128, 63, 0, 0, 0, 0, 0, 0,
  84. 0, 0, 96, 65, 54, 0, 0, 0, 0, 0,128, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  85. 0, 0, 0, 0,128, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128, 63,
  86. 53,169, 40, 65,176,205, 90,191, 0, 0, 0, 0, 32, 65,158, 0, 0, 0, 12, 0, 0, 0,
  87. 2, 0, 3, 0, 6, 0, 3, 0, 1, 0, 0, 0, 6, 0, 4, 0, 5, 0, 7, 0, 6, 0,
  88. 7, 0, 6, 0, 4, 0, 6, 0, 8, 0, 9, 0, 10, 0, 6, 0, 11, 0, 12, 0, 13, 0,
  89. 6, 0, 1, 0, 14, 0, 7, 0, 6, 0, 7, 0, 15, 0, 1, 0, 6, 0, 16, 0, 17, 0,
  90. 18, 0, 6, 0, 19, 0, 20, 0, 21, 0, 6, 0, 22, 0, 0, 0, 23, 0, 6, 0, 24, 0,
  91. 6, 0, 25, 0, 6, 0, 80, 65, 54, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 4, 0,
  92. 0, 0, 4, 0, 0, 0, 8, 0, 0, 0, 8, 0, 0, 0, 16, 0, 0, 0, 16, 0, 0, 0,
  93. 32, 0, 0, 0, 32, 0, 0, 0, 64, 0, 0, 0, 64, 0, 0, 0, 0, 64, 67, 0, 0, 0,
  94. 67, 97,109,101,114, 97, 48, 49, 0, 0, 71, 52, 0, 0, 0,189, 19, 25,195,136,104, 81,
  95. 64,147, 56,182, 65, 96,233, 20,194, 67,196, 97,190,147, 56,182, 65, 0, 0, 0, 0, 85,
  96. 85, 85, 66, 32, 71, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0,122, 68, 0,176,179, 1, 0,
  97. 0, 10,176, 21, 0, 0, 0, 5, 0, 77, 65, 88, 83, 67, 69, 78, 69, 0, 44, 1, 0, 0,
  98. 8,176, 14, 0, 0, 0, 0, 0, 0, 0, 44, 1, 0, 0, 9,176, 10, 0, 0, 0,128, 2,
  99. 0, 0, 2,176,168, 0, 0, 0, 48,176, 8, 0, 0, 0, 0, 0, 16,176, 18, 0, 0, 0,
  100. 66,111,120, 48, 49, 0, 0, 64, 0, 0,255,255, 19,176, 18, 0, 0, 0, 0, 0, 0,128,
  101. 0, 0, 0,128, 0, 0, 0,128, 32,176, 38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  102. 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 53,169, 40, 65,176,205, 90,191, 0, 0,
  103. 0, 0, 33,176, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
  104. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  105. 34,176, 38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
  106. 0, 0, 0, 0, 0, 0,128, 63, 0, 0,128, 63, 0, 0,128, 63, 3,176,143, 0, 0, 0,
  107. 48,176, 8, 0, 0, 0, 1, 0, 16,176, 21, 0, 0, 0, 67, 97,109,101,114, 97, 48, 49,
  108. 0, 0, 64, 0, 0,255,255, 32,176, 38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  109. 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,189, 19, 25,195,136,104, 81, 64,147, 56,182,
  110. 65, 35,176, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
  111. 0, 0, 0, 0, 0, 0, 0, 52, 66, 36,176, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0,120,
  112. 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0,120, 13, 90,189,120, 0, 0, 0, 0,
  113. 0, 99,156,154,194, 4,176, 73, 0, 0, 0, 48,176, 8, 0, 0, 0, 2, 0, 16,176, 21,
  114. 0, 0, 0, 67, 97,109,101,114, 97, 48, 49, 0, 0, 64, 0, 0,255,255, 32,176, 38, 0,
  115. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  116. 96,233, 20,194, 67,196, 97,190,147, 56,182, 65 };
  117. // clang-format on
  118. #define AIUT_DEF_ERROR_TEXT "sorry, this is a test"
  119. static const aiImporterDesc desc = {
  120. "UNIT TEST - IMPORTER",
  121. "",
  122. "",
  123. "",
  124. 0,
  125. 0,
  126. 0,
  127. 0,
  128. 0,
  129. "apple mac linux windows"
  130. };
  131. class TestPlugin : public BaseImporter {
  132. public:
  133. virtual bool CanRead(
  134. const std::string &pFile, IOSystem * /*pIOHandler*/, bool /*test*/) const {
  135. std::string::size_type pos = pFile.find_last_of('.');
  136. // no file extension - can't read
  137. if (pos == std::string::npos)
  138. return false;
  139. std::string extension = pFile.substr(pos);
  140. // todo ... make case-insensitive
  141. return (extension == ".apple" || extension == ".mac" ||
  142. extension == ".linux" || extension == ".windows");
  143. }
  144. virtual const aiImporterDesc *GetInfo() const {
  145. return &desc;
  146. }
  147. virtual void InternReadFile(
  148. const std::string & /*pFile*/, aiScene * /*pScene*/, IOSystem * /*pIOHandler*/) {
  149. throw DeadlyImportError(AIUT_DEF_ERROR_TEXT);
  150. }
  151. };
  152. // ------------------------------------------------------------------------------------------------
  153. TEST_F(ImporterTest, testMemoryRead) {
  154. const aiScene *sc = pImp->ReadFileFromMemory(InputData_abRawBlock, InputData_BLOCK_SIZE,
  155. aiProcessPreset_TargetRealtime_Quality, "3ds");
  156. ASSERT_TRUE(sc != nullptr);
  157. EXPECT_EQ(aiString("<3DSRoot>"), sc->mRootNode->mName);
  158. EXPECT_EQ(1U, sc->mNumMeshes);
  159. EXPECT_EQ(24U, sc->mMeshes[0]->mNumVertices);
  160. EXPECT_EQ(12U, sc->mMeshes[0]->mNumFaces);
  161. }
  162. // ------------------------------------------------------------------------------------------------
  163. TEST_F(ImporterTest, testIntProperty) {
  164. bool b = pImp->SetPropertyInteger("quakquak", 1503);
  165. EXPECT_FALSE(b);
  166. EXPECT_EQ(1503, pImp->GetPropertyInteger("quakquak", 0));
  167. EXPECT_EQ(314159, pImp->GetPropertyInteger("not_there", 314159));
  168. b = pImp->SetPropertyInteger("quakquak", 1504);
  169. EXPECT_TRUE(b);
  170. }
  171. // ------------------------------------------------------------------------------------------------
  172. TEST_F(ImporterTest, testFloatProperty) {
  173. bool b = pImp->SetPropertyFloat("quakquak", 1503.f);
  174. EXPECT_TRUE(!b);
  175. EXPECT_EQ(1503.f, pImp->GetPropertyFloat("quakquak", 0.f));
  176. EXPECT_EQ(314159.f, pImp->GetPropertyFloat("not_there", 314159.f));
  177. }
  178. // ------------------------------------------------------------------------------------------------
  179. TEST_F(ImporterTest, testStringProperty) {
  180. bool b = pImp->SetPropertyString("quakquak", "test");
  181. EXPECT_TRUE(!b);
  182. EXPECT_EQ("test", pImp->GetPropertyString("quakquak", "weghwekg"));
  183. EXPECT_EQ("ILoveYou", pImp->GetPropertyString("not_there", "ILoveYou"));
  184. }
  185. // ------------------------------------------------------------------------------------------------
  186. TEST_F(ImporterTest, testPluginInterface) {
  187. pImp->RegisterLoader(new TestPlugin());
  188. EXPECT_TRUE(pImp->IsExtensionSupported(".apple"));
  189. EXPECT_TRUE(pImp->IsExtensionSupported(".mac"));
  190. EXPECT_TRUE(pImp->IsExtensionSupported("*.linux"));
  191. EXPECT_TRUE(pImp->IsExtensionSupported("windows"));
  192. EXPECT_TRUE(pImp->IsExtensionSupported(".x")); /* x and 3ds must be available in this Assimp build, of course! */
  193. EXPECT_TRUE(pImp->IsExtensionSupported(".3ds"));
  194. EXPECT_FALSE(pImp->IsExtensionSupported("."));
  195. TestPlugin *p = (TestPlugin *)pImp->GetImporter(".windows");
  196. ASSERT_TRUE(nullptr != p);
  197. try {
  198. p->InternReadFile("", nullptr, nullptr);
  199. } catch (const DeadlyImportError &dead) {
  200. EXPECT_TRUE(!strcmp(dead.what(), AIUT_DEF_ERROR_TEXT));
  201. // unregister the plugin and delete it
  202. pImp->UnregisterLoader(p);
  203. delete p;
  204. return;
  205. }
  206. EXPECT_TRUE(false); // control shouldn't reach this point
  207. }
  208. // ------------------------------------------------------------------------------------------------
  209. TEST_F(ImporterTest, testExtensionCheck) {
  210. std::string s;
  211. pImp->GetExtensionList(s);
  212. // TODO
  213. }
  214. // ------------------------------------------------------------------------------------------------
  215. TEST_F(ImporterTest, testMultipleReads) {
  216. // see http://sourceforge.net/projects/assimp/forums/forum/817654/topic/3591099
  217. // Check whether reading and post-processing multiple times using
  218. // the same objects is *generally* fine. This test doesn't target
  219. // importers. Testing post-processing stability is the main point.
  220. const unsigned int flags =
  221. aiProcess_Triangulate |
  222. aiProcess_JoinIdenticalVertices |
  223. aiProcess_GenSmoothNormals |
  224. aiProcess_ValidateDataStructure |
  225. aiProcess_RemoveRedundantMaterials |
  226. aiProcess_SortByPType |
  227. aiProcess_FindDegenerates |
  228. aiProcess_FindInvalidData |
  229. aiProcess_GenUVCoords |
  230. aiProcess_OptimizeMeshes |
  231. aiProcess_OptimizeGraph;
  232. EXPECT_TRUE(pImp->ReadFile(ASSIMP_TEST_MODELS_DIR "/X/test.x", flags));
  233. //EXPECT_TRUE(pImp->ReadFile(ASSIMP_TEST_MODELS_DIR "/X/dwarf.x",flags)); # is in nonbsd
  234. EXPECT_TRUE(pImp->ReadFile(ASSIMP_TEST_MODELS_DIR "/X/Testwuson.X", flags));
  235. EXPECT_TRUE(pImp->ReadFile(ASSIMP_TEST_MODELS_DIR "/X/anim_test.x", flags));
  236. //EXPECT_TRUE(pImp->ReadFile(ASSIMP_TEST_MODELS_DIR "/X/dwarf.x",flags)); # is in nonbsd
  237. EXPECT_TRUE(pImp->ReadFile(ASSIMP_TEST_MODELS_DIR "/X/anim_test.x", flags));
  238. EXPECT_TRUE(pImp->ReadFile(ASSIMP_TEST_MODELS_DIR "/X/BCN_Epileptic.X", flags));
  239. //EXPECT_TRUE(pImp->ReadFile(ASSIMP_TEST_MODELS_DIR "/X/dwarf.x",flags)); # is in nonbsd
  240. }
  241. TEST_F(ImporterTest, SearchFileHeaderForTokenTest) {
  242. //DefaultIOSystem ioSystem;
  243. // BaseImporter::SearchFileHeaderForToken( &ioSystem, assetPath, Token, 2 )
  244. }
  245. namespace {
  246. // Description for an importer which fails in specific ways.
  247. aiImporterDesc s_failingImporterDescription = {
  248. "Failing importer",
  249. "assimp team",
  250. "",
  251. "",
  252. 0,
  253. 1,
  254. 0,
  255. 1,
  256. 0,
  257. "fail"
  258. };
  259. // This importer fails in specific ways.
  260. class FailingImporter : public Assimp::BaseImporter {
  261. public:
  262. virtual ~FailingImporter() = default;
  263. bool CanRead(const std::string &, Assimp::IOSystem *, bool) const override {
  264. return true;
  265. }
  266. protected:
  267. const aiImporterDesc *GetInfo() const override {
  268. return &s_failingImporterDescription;
  269. }
  270. void InternReadFile(const std::string &pFile, aiScene *, Assimp::IOSystem *) override {
  271. if (pFile == "deadlyImportError.fail") {
  272. throw DeadlyImportError("Deadly import error test. Details: ", 42, " More Details: ", "Failure");
  273. } else if (pFile == "stdException.fail") {
  274. throw std::runtime_error("std::exception test");
  275. } else if (pFile == "unexpectedException.fail") {
  276. throw 5;
  277. }
  278. }
  279. };
  280. } // namespace
  281. TEST_F(ImporterTest, deadlyImportError) {
  282. pImp->RegisterLoader(new FailingImporter);
  283. pImp->SetIOHandler(new TestIOSystem);
  284. const aiScene *scene = pImp->ReadFile("deadlyImportError.fail", 0);
  285. EXPECT_EQ(scene, nullptr);
  286. EXPECT_STREQ(pImp->GetErrorString(), "Deadly import error test. Details: 42 More Details: Failure");
  287. EXPECT_NE(pImp->GetException(), std::exception_ptr());
  288. }
  289. TEST_F(ImporterTest, stdException) {
  290. pImp->RegisterLoader(new FailingImporter);
  291. pImp->SetIOHandler(new TestIOSystem);
  292. const aiScene *scene = pImp->ReadFile("stdException.fail", 0);
  293. EXPECT_EQ(scene, nullptr);
  294. EXPECT_STREQ(pImp->GetErrorString(), "std::exception test");
  295. EXPECT_NE(pImp->GetException(), std::exception_ptr());
  296. try {
  297. std::rethrow_exception(pImp->GetException());
  298. } catch (const std::exception &e) {
  299. EXPECT_STREQ(e.what(), "std::exception test");
  300. } catch (...) {
  301. EXPECT_TRUE(false);
  302. }
  303. }
  304. TEST_F(ImporterTest, unexpectedException) {
  305. pImp->RegisterLoader(new FailingImporter);
  306. pImp->SetIOHandler(new TestIOSystem);
  307. const aiScene *scene = pImp->ReadFile("unexpectedException.fail", 0);
  308. EXPECT_EQ(scene, nullptr);
  309. EXPECT_STREQ(pImp->GetErrorString(), "Unknown exception");
  310. ASSERT_NE(pImp->GetException(), std::exception_ptr());
  311. try {
  312. std::rethrow_exception(pImp->GetException());
  313. } catch (int x) {
  314. EXPECT_EQ(x, 5);
  315. } catch (...) {
  316. EXPECT_TRUE(false);
  317. }
  318. }
  319. // ------------------------------------------------------------------------------------------------
  320. struct ExtensionTestCase {
  321. std::string testName;
  322. std::string filename;
  323. std::string getExtensionResult;
  324. std::string hasExtension;
  325. bool hasExtensionResult;
  326. };
  327. using ExtensionTest = ::testing::TestWithParam<ExtensionTestCase>;
  328. TEST_P(ExtensionTest, testGetAndHasExtension) {
  329. const ExtensionTestCase& testCase = GetParam();
  330. EXPECT_EQ(testCase.getExtensionResult, BaseImporter::GetExtension(testCase.filename));
  331. EXPECT_EQ(testCase.hasExtensionResult, BaseImporter::HasExtension(testCase.filename, {testCase.hasExtension}));
  332. }
  333. INSTANTIATE_TEST_SUITE_P(
  334. ExtensionTests, ExtensionTest,
  335. ::testing::ValuesIn<ExtensionTestCase>({
  336. {"NoExtension", "name", "", "glb", false},
  337. {"NoExtensionAndEmptyVersion", "name#", "", "glb", false},
  338. {"WithExtensionAndEmptyVersion", "name.glb#", "glb#", "glb", false},
  339. {"WithExtensionAndVersion", "name.glb#1234", "glb", "glb", true},
  340. {"WithExtensionAndHashInStem", "name#1234.glb", "glb", "glb", true},
  341. {"WithExtensionAndInvalidVersion", "name.glb#_", "glb#_", "glb", false},
  342. {"WithExtensionAndDotAndHashInStem", "name.glb#.abc", "abc", "glb", false},
  343. {"WithTwoExtensions", "name.abc.def", "def", "abc.def", true},
  344. }),
  345. [](const ::testing::TestParamInfo<ExtensionTest::ParamType>& info) {
  346. return info.param.testName;
  347. });