summaryrefslogtreecommitdiff
path: root/src/mmo/extract_test.cpp
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2014-03-15 19:34:59 -0700
committerBen Longbons <b.r.longbons@gmail.com>2014-03-16 18:58:48 -0700
commitc812c92d1a1835f0bda783e709481188c8d92225 (patch)
treeb401ede48a088ad1aaed88fe3b997cd26ff7ae08 /src/mmo/extract_test.cpp
parentde9ee1b9754af9d954487121947352f32d7ebb7e (diff)
downloadtmwa-c812c92d1a1835f0bda783e709481188c8d92225.tar.gz
tmwa-c812c92d1a1835f0bda783e709481188c8d92225.tar.bz2
tmwa-c812c92d1a1835f0bda783e709481188c8d92225.tar.xz
tmwa-c812c92d1a1835f0bda783e709481188c8d92225.zip
Clean up header organization
Diffstat (limited to 'src/mmo/extract_test.cpp')
-rw-r--r--src/mmo/extract_test.cpp334
1 files changed, 334 insertions, 0 deletions
diff --git a/src/mmo/extract_test.cpp b/src/mmo/extract_test.cpp
new file mode 100644
index 0000000..3d0610e
--- /dev/null
+++ b/src/mmo/extract_test.cpp
@@ -0,0 +1,334 @@
+#include "extract.hpp"
+
+#include <gtest/gtest.h>
+
+#include "../strings/xstring.hpp"
+
+TEST(extract, record_int)
+{
+ int x, y, z;
+ x = y = z = 0;
+ EXPECT_FALSE(extract("1 2 3 4 ", record<' '>(&x, &y, &z)));
+ EXPECT_EQ(1, x);
+ EXPECT_EQ(2, y);
+ EXPECT_EQ(3, z);
+ x = y = z = 0;
+ EXPECT_FALSE(extract("1 2 3 4", record<' '>(&x, &y, &z)));
+ EXPECT_EQ(1, x);
+ EXPECT_EQ(2, y);
+ EXPECT_EQ(3, z);
+ x = y = z = 0;
+ EXPECT_TRUE(extract("1 2 3 ", record<' '>(&x, &y, &z)));
+ EXPECT_EQ(1, x);
+ EXPECT_EQ(2, y);
+ EXPECT_EQ(3, z);
+ x = y = z = 0;
+ EXPECT_TRUE(extract("1 2 3", record<' '>(&x, &y, &z)));
+ EXPECT_EQ(1, x);
+ EXPECT_EQ(2, y);
+ EXPECT_EQ(3, z);
+ x = y = z = 0;
+ EXPECT_FALSE(extract("1 2 ", record<' '>(&x, &y, &z)));
+ EXPECT_EQ(1, x);
+ EXPECT_EQ(2, y);
+ EXPECT_EQ(0, z);
+ x = y = z = 0;
+ EXPECT_FALSE(extract("1 2", record<' '>(&x, &y, &z)));
+ EXPECT_EQ(1, x);
+ EXPECT_EQ(2, y);
+ EXPECT_EQ(0, z);
+ x = y = z = 0;
+ EXPECT_FALSE(extract("1 ", record<' '>(&x, &y, &z)));
+ EXPECT_EQ(1, x);
+ EXPECT_EQ(0, y);
+ EXPECT_EQ(0, z);
+ x = y = z = 0;
+ EXPECT_FALSE(extract("1", record<' '>(&x, &y, &z)));
+ EXPECT_EQ(1, x);
+ EXPECT_EQ(0, y);
+ EXPECT_EQ(0, z);
+ x = y = z = 0;
+ EXPECT_FALSE(extract(" ", record<' '>(&x, &y, &z)));
+ EXPECT_EQ(0, x);
+ EXPECT_EQ(0, y);
+ EXPECT_EQ(0, z);
+ x = y = z = 0;
+ EXPECT_FALSE(extract("", record<' '>(&x, &y, &z)));
+ EXPECT_EQ(0, x);
+ EXPECT_EQ(0, y);
+ EXPECT_EQ(0, z);
+ x = y = z = 0;
+
+ EXPECT_FALSE(extract("1 2 3 4 ", record<' ', 2>(&x, &y, &z)));
+ EXPECT_EQ(1, x);
+ EXPECT_EQ(2, y);
+ EXPECT_EQ(3, z);
+ x = y = z = 0;
+ EXPECT_FALSE(extract("1 2 3 4", record<' ', 2>(&x, &y, &z)));
+ EXPECT_EQ(1, x);
+ EXPECT_EQ(2, y);
+ EXPECT_EQ(3, z);
+ x = y = z = 0;
+ EXPECT_TRUE(extract("1 2 3 ", record<' ', 2>(&x, &y, &z)));
+ EXPECT_EQ(1, x);
+ EXPECT_EQ(2, y);
+ EXPECT_EQ(3, z);
+ x = y = z = 0;
+ EXPECT_TRUE(extract("1 2 3", record<' ', 2>(&x, &y, &z)));
+ EXPECT_EQ(1, x);
+ EXPECT_EQ(2, y);
+ EXPECT_EQ(3, z);
+ x = y = z = 0;
+ EXPECT_TRUE(extract("1 2 ", record<' ', 2>(&x, &y, &z)));
+ EXPECT_EQ(1, x);
+ EXPECT_EQ(2, y);
+ EXPECT_EQ(0, z);
+ x = y = z = 0;
+ EXPECT_TRUE(extract("1 2", record<' ', 2>(&x, &y, &z)));
+ EXPECT_EQ(1, x);
+ EXPECT_EQ(2, y);
+ EXPECT_EQ(0, z);
+ x = y = z = 0;
+ EXPECT_FALSE(extract("1 ", record<' ', 2>(&x, &y, &z)));
+ EXPECT_EQ(1, x);
+ EXPECT_EQ(0, y);
+ EXPECT_EQ(0, z);
+ x = y = z = 0;
+ EXPECT_FALSE(extract("1", record<' ', 2>(&x, &y, &z)));
+ EXPECT_EQ(1, x);
+ EXPECT_EQ(0, y);
+ EXPECT_EQ(0, z);
+ x = y = z = 0;
+ EXPECT_FALSE(extract(" ", record<' ', 2>(&x, &y, &z)));
+ EXPECT_EQ(0, x);
+ EXPECT_EQ(0, y);
+ EXPECT_EQ(0, z);
+ x = y = z = 0;
+ EXPECT_FALSE(extract("", record<' ', 2>(&x, &y, &z)));
+ EXPECT_EQ(0, x);
+ EXPECT_EQ(0, y);
+ EXPECT_EQ(0, z);
+ x = y = z = 0;
+
+ EXPECT_FALSE(extract("1 2 3 4 ", record<' ', 1>(&x, &y, &z)));
+ EXPECT_EQ(1, x);
+ EXPECT_EQ(2, y);
+ EXPECT_EQ(3, z);
+ x = y = z = 0;
+ EXPECT_FALSE(extract("1 2 3 4", record<' ', 1>(&x, &y, &z)));
+ EXPECT_EQ(1, x);
+ EXPECT_EQ(2, y);
+ EXPECT_EQ(3, z);
+ x = y = z = 0;
+ EXPECT_TRUE(extract("1 2 3 ", record<' ', 1>(&x, &y, &z)));
+ EXPECT_EQ(1, x);
+ EXPECT_EQ(2, y);
+ EXPECT_EQ(3, z);
+ x = y = z = 0;
+ EXPECT_TRUE(extract("1 2 3", record<' ', 1>(&x, &y, &z)));
+ EXPECT_EQ(1, x);
+ EXPECT_EQ(2, y);
+ EXPECT_EQ(3, z);
+ x = y = z = 0;
+ EXPECT_TRUE(extract("1 2 ", record<' ', 1>(&x, &y, &z)));
+ EXPECT_EQ(1, x);
+ EXPECT_EQ(2, y);
+ EXPECT_EQ(0, z);
+ x = y = z = 0;
+ EXPECT_TRUE(extract("1 2", record<' ', 1>(&x, &y, &z)));
+ EXPECT_EQ(1, x);
+ EXPECT_EQ(2, y);
+ EXPECT_EQ(0, z);
+ x = y = z = 0;
+ EXPECT_TRUE(extract("1 ", record<' ', 1>(&x, &y, &z)));
+ EXPECT_EQ(1, x);
+ EXPECT_EQ(0, y);
+ EXPECT_EQ(0, z);
+ x = y = z = 0;
+ EXPECT_TRUE(extract("1", record<' ', 1>(&x, &y, &z)));
+ EXPECT_EQ(1, x);
+ EXPECT_EQ(0, y);
+ EXPECT_EQ(0, z);
+ x = y = z = 0;
+ EXPECT_FALSE(extract(" ", record<' ', 1>(&x, &y, &z)));
+ EXPECT_EQ(0, x);
+ EXPECT_EQ(0, y);
+ EXPECT_EQ(0, z);
+ x = y = z = 0;
+ EXPECT_FALSE(extract("", record<' ', 1>(&x, &y, &z)));
+ EXPECT_EQ(0, x);
+ EXPECT_EQ(0, y);
+ EXPECT_EQ(0, z);
+ x = y = z = 0;
+}
+
+TEST(extract, record_str)
+{
+ XString x, y, z;
+ x = y = z = "";
+ EXPECT_FALSE(extract("1 2 3 4 ", record<' '>(&x, &y, &z)));
+ EXPECT_EQ("1", x);
+ EXPECT_EQ("2", y);
+ EXPECT_EQ("3", z);
+ x = y = z = "";
+ EXPECT_FALSE(extract("1 2 3 4", record<' '>(&x, &y, &z)));
+ EXPECT_EQ("1", x);
+ EXPECT_EQ("2", y);
+ EXPECT_EQ("3", z);
+ x = y = z = "";
+ EXPECT_TRUE(extract("1 2 3 ", record<' '>(&x, &y, &z)));
+ EXPECT_EQ("1", x);
+ EXPECT_EQ("2", y);
+ EXPECT_EQ("3", z);
+ x = y = z = "";
+ EXPECT_TRUE(extract("1 2 3", record<' '>(&x, &y, &z)));
+ EXPECT_EQ("1", x);
+ EXPECT_EQ("2", y);
+ EXPECT_EQ("3", z);
+ x = y = z = "";
+ EXPECT_TRUE(extract("1 2 ", record<' '>(&x, &y, &z)));
+ EXPECT_EQ("1", x);
+ EXPECT_EQ("2", y);
+ EXPECT_EQ("", z);
+ x = y = z = "";
+ EXPECT_FALSE(extract("1 2", record<' '>(&x, &y, &z)));
+ EXPECT_EQ("1", x);
+ EXPECT_EQ("2", y);
+ EXPECT_EQ("", z);
+ x = y = z = "";
+ EXPECT_FALSE(extract("1 ", record<' '>(&x, &y, &z)));
+ EXPECT_EQ("1", x);
+ EXPECT_EQ("", y);
+ EXPECT_EQ("", z);
+ x = y = z = "";
+ EXPECT_FALSE(extract("1", record<' '>(&x, &y, &z)));
+ EXPECT_EQ("1", x);
+ EXPECT_EQ("", y);
+ EXPECT_EQ("", z);
+ x = y = z = "";
+ EXPECT_FALSE(extract(" ", record<' '>(&x, &y, &z)));
+ EXPECT_EQ("", x);
+ EXPECT_EQ("", y);
+ EXPECT_EQ("", z);
+ x = y = z = "";
+ EXPECT_FALSE(extract("", record<' '>(&x, &y, &z)));
+ EXPECT_EQ("", x);
+ EXPECT_EQ("", y);
+ EXPECT_EQ("", z);
+ x = y = z = "";
+
+ EXPECT_FALSE(extract("1 2 3 4 ", record<' ', 2>(&x, &y, &z)));
+ EXPECT_EQ("1", x);
+ EXPECT_EQ("2", y);
+ EXPECT_EQ("3", z);
+ x = y = z = "";
+ EXPECT_FALSE(extract("1 2 3 4", record<' ', 2>(&x, &y, &z)));
+ EXPECT_EQ("1", x);
+ EXPECT_EQ("2", y);
+ EXPECT_EQ("3", z);
+ x = y = z = "";
+ EXPECT_TRUE(extract("1 2 3 ", record<' ', 2>(&x, &y, &z)));
+ EXPECT_EQ("1", x);
+ EXPECT_EQ("2", y);
+ EXPECT_EQ("3", z);
+ x = y = z = "";
+ EXPECT_TRUE(extract("1 2 3", record<' ', 2>(&x, &y, &z)));
+ EXPECT_EQ("1", x);
+ EXPECT_EQ("2", y);
+ EXPECT_EQ("3", z);
+ x = y = z = "";
+ EXPECT_TRUE(extract("1 2 ", record<' ', 2>(&x, &y, &z)));
+ EXPECT_EQ("1", x);
+ EXPECT_EQ("2", y);
+ EXPECT_EQ("", z);
+ x = y = z = "";
+ EXPECT_TRUE(extract("1 2", record<' ', 2>(&x, &y, &z)));
+ EXPECT_EQ("1", x);
+ EXPECT_EQ("2", y);
+ EXPECT_EQ("", z);
+ x = y = z = "";
+ EXPECT_TRUE(extract("1 ", record<' ', 2>(&x, &y, &z)));
+ EXPECT_EQ("1", x);
+ EXPECT_EQ("", y);
+ EXPECT_EQ("", z);
+ x = y = z = "";
+ EXPECT_FALSE(extract("1", record<' ', 2>(&x, &y, &z)));
+ EXPECT_EQ("1", x);
+ EXPECT_EQ("", y);
+ EXPECT_EQ("", z);
+ x = y = z = "";
+ EXPECT_TRUE(extract(" ", record<' ', 2>(&x, &y, &z)));
+ EXPECT_EQ("", x);
+ EXPECT_EQ("", y);
+ EXPECT_EQ("", z);
+ x = y = z = "";
+ EXPECT_FALSE(extract("", record<' ', 2>(&x, &y, &z)));
+ EXPECT_EQ("", x);
+ EXPECT_EQ("", y);
+ EXPECT_EQ("", z);
+ x = y = z = "";
+
+ EXPECT_FALSE(extract("1 2 3 4 ", record<' ', 1>(&x, &y, &z)));
+ EXPECT_EQ("1", x);
+ EXPECT_EQ("2", y);
+ EXPECT_EQ("3", z);
+ x = y = z = "";
+ EXPECT_FALSE(extract("1 2 3 4", record<' ', 1>(&x, &y, &z)));
+ EXPECT_EQ("1", x);
+ EXPECT_EQ("2", y);
+ EXPECT_EQ("3", z);
+ x = y = z = "";
+ EXPECT_TRUE(extract("1 2 3 ", record<' ', 1>(&x, &y, &z)));
+ EXPECT_EQ("1", x);
+ EXPECT_EQ("2", y);
+ EXPECT_EQ("3", z);
+ x = y = z = "";
+ EXPECT_TRUE(extract("1 2 3", record<' ', 1>(&x, &y, &z)));
+ EXPECT_EQ("1", x);
+ EXPECT_EQ("2", y);
+ EXPECT_EQ("3", z);
+ x = y = z = "";
+ EXPECT_TRUE(extract("1 2 ", record<' ', 1>(&x, &y, &z)));
+ EXPECT_EQ("1", x);
+ EXPECT_EQ("2", y);
+ EXPECT_EQ("", z);
+ x = y = z = "";
+ EXPECT_TRUE(extract("1 2", record<' ', 1>(&x, &y, &z)));
+ EXPECT_EQ("1", x);
+ EXPECT_EQ("2", y);
+ EXPECT_EQ("", z);
+ x = y = z = "";
+ EXPECT_TRUE(extract("1 ", record<' ', 1>(&x, &y, &z)));
+ EXPECT_EQ("1", x);
+ EXPECT_EQ("", y);
+ EXPECT_EQ("", z);
+ x = y = z = "";
+ EXPECT_TRUE(extract("1", record<' ', 1>(&x, &y, &z)));
+ EXPECT_EQ("1", x);
+ EXPECT_EQ("", y);
+ EXPECT_EQ("", z);
+ x = y = z = "";
+ EXPECT_TRUE(extract(" ", record<' ', 1>(&x, &y, &z)));
+ EXPECT_EQ("", x);
+ EXPECT_EQ("", y);
+ EXPECT_EQ("", z);
+ x = y = z = "";
+ EXPECT_TRUE(extract("", record<' ', 1>(&x, &y, &z)));
+ EXPECT_EQ("", x);
+ EXPECT_EQ("", y);
+ EXPECT_EQ("", z);
+ x = y = z = "";
+}
+
+TEST(extract, mapname)
+{
+ MapName map;
+ EXPECT_TRUE(extract("abc", &map));
+ EXPECT_EQ(map, "abc");
+ EXPECT_TRUE(extract("abc.gat", &map));
+ EXPECT_EQ(map, "abc");
+ EXPECT_TRUE(extract("abcdefghijklmno", &map));
+ EXPECT_EQ(map, "abcdefghijklmno");
+ EXPECT_TRUE(extract("abcdefghijklmno.gat", &map));
+ EXPECT_EQ(map, "abcdefghijklmno");
+}