testing: parser
[m6w6/libmemcached] / test / tests / memcached / parser.cpp
index ca7fa4001237a13d089564dc7c52b7f04402118e..20fbed415e5d74613be5fad9dd139df3f8c57ba9 100644 (file)
@@ -1,6 +1,9 @@
 #include "test/lib/common.hpp"
 #include "test/lib/env.hpp"
 
+#include "libmemcached/common.h"
+#include "test/fixtures/parser.hpp"
+
 TEST_CASE("memcached_parser") {
   SECTION("fail: null string") {
     REQUIRE_FALSE(memcached(nullptr, 123));
@@ -31,4 +34,18 @@ TEST_CASE("memcached_parser") {
       REQUIRE_FALSE(memcached(nullptr, 0));
     }
   }
+
+  SECTION("fixtures") {
+    for (const auto &test : tests) {
+      DYNAMIC_SECTION(test.name) {
+        for (size_t i = 0; i < test.ntests; ++i) {
+          auto &tc = test.tests[i];
+          DYNAMIC_SECTION(tc.option.c_str) {
+            MemcachedPtr memc(memcached(tc.option.c_str, tc.option.size));
+            test.check(*memc, tc.result);
+          }
+        }
+      }
+    }
+  }
 }