summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2014-12-29 13:56:16 -0800
committerTom Sepez <tsepez@chromium.org>2014-12-29 13:56:16 -0800
commit336991da7a3d5682a572c01e0a149b6990d05594 (patch)
treee6e6613beae3ff78c9e358555b72e495af3bf468
parent6c06469226a127bbbca103c08d282fe2e711c89d (diff)
downloadpdfium-336991da7a3d5682a572c01e0a149b6990d05594.tar.xz
Create pdfium_unittests binary.
PDFium has not yet had a unit-tests binary, so introduce one based on the typical gtest framework. Also provide a small initial test fragment for fxcrt strings for instructional purposes. Naturally, doing so kicked out one corner case that isn't handled, we'll fix that in a separate patch. This is a small part of the testing strategy tracking bug. BUG=https://code.google.com/p/pdfium/issues/detail?id=62 R=brucedawson@chromium.org, palmer@chromium.org Review URL: https://codereview.chromium.org/831653002
-rw-r--r--BUILD.gn13
-rw-r--r--core/src/fxcrt/fx_basic_bstring_unittest.cpp42
-rw-r--r--pdfium.gyp16
3 files changed, 71 insertions, 0 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 2076afb87a..a442e79394 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -791,3 +791,16 @@ static_library("formfiller") {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ ":pdfium_config", "//build/config/compiler:no_chromium_code" ]
}
+
+executable("pdfium_unittests") {
+ testonly = true
+ sources = [
+ "core/src/fxcrt/fx_basic_bstring_unittest.cpp",
+ ]
+ deps = [
+ ":pdfium",
+ "//base",
+ "//base/test:run_all_unittests",
+ "//testing/gtest",
+ ]
+}
diff --git a/core/src/fxcrt/fx_basic_bstring_unittest.cpp b/core/src/fxcrt/fx_basic_bstring_unittest.cpp
new file mode 100644
index 0000000000..cf5e05d1ef
--- /dev/null
+++ b/core/src/fxcrt/fx_basic_bstring_unittest.cpp
@@ -0,0 +1,42 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+#include "../../include/fxcrt/fx_basic.h"
+
+TEST(fxcrt, ByteStringCNull) {
+ CFX_ByteStringC null_string;
+ EXPECT_EQ(null_string.GetPtr(), nullptr);
+ EXPECT_EQ(null_string.GetLength(), 0);
+ EXPECT_TRUE(null_string.IsEmpty());
+
+ CFX_ByteStringC another_null_string;
+ EXPECT_TRUE(null_string == another_null_string);
+
+ CFX_ByteString copied_null_string(null_string);
+ EXPECT_EQ(null_string.GetPtr(), nullptr);
+ EXPECT_EQ(null_string.GetLength(), 0);
+ EXPECT_TRUE(null_string.IsEmpty());
+ EXPECT_TRUE(null_string == another_null_string);
+
+ CFX_ByteStringC empty_string("");
+ EXPECT_EQ(null_string.GetPtr(), nullptr);
+ EXPECT_EQ(null_string.GetLength(), 0);
+ EXPECT_TRUE(null_string.IsEmpty());
+ EXPECT_TRUE(null_string == empty_string);
+
+ CFX_ByteStringC non_null_string("a");
+ EXPECT_FALSE(null_string == non_null_string);
+
+ // TODO(tsepez): fix assignment of a null ptr to a CFX_ByteStringC.
+}
+
+TEST(fxcrt, ByteStringCGetID) {
+ CFX_ByteStringC null_string;
+ EXPECT_EQ(null_string.GetID(), 0u);
+
+ CFX_ByteStringC empty_string("");
+ EXPECT_EQ(empty_string.GetID(), 0u);
+}
diff --git a/pdfium.gyp b/pdfium.gyp
index 15e7df0e4c..d48eba170b 100644
--- a/pdfium.gyp
+++ b/pdfium.gyp
@@ -802,5 +802,21 @@
'fpdfsdk/src/formfiller/FFL_Utils.cpp',
],
},
+ {
+ 'target_name': 'pdfium_unittests',
+ 'type': 'executable',
+ 'dependencies': [
+ '../../base/base.gyp:base_prefs',
+ '../../base/base.gyp:run_all_unittests',
+ '../../testing/gtest.gyp:gtest',
+ 'pdfium',
+ ],
+ 'include_dirs': [
+ '<(DEPTH)'
+ ],
+ 'sources': [
+ 'core/src/fxcrt/fx_basic_bstring_unittest.cpp',
+ ],
+ }
],
}