summaryrefslogtreecommitdiffstats
path: root/searchlib/src/tests/prettyfloat
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
committerJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
commit72231250ed81e10d66bfe70701e64fa5fe50f712 (patch)
tree2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /searchlib/src/tests/prettyfloat
Publish
Diffstat (limited to 'searchlib/src/tests/prettyfloat')
-rw-r--r--searchlib/src/tests/prettyfloat/.gitignore4
-rw-r--r--searchlib/src/tests/prettyfloat/CMakeLists.txt8
-rw-r--r--searchlib/src/tests/prettyfloat/DESC1
-rw-r--r--searchlib/src/tests/prettyfloat/FILES1
-rw-r--r--searchlib/src/tests/prettyfloat/prettyfloat.cpp32
5 files changed, 46 insertions, 0 deletions
diff --git a/searchlib/src/tests/prettyfloat/.gitignore b/searchlib/src/tests/prettyfloat/.gitignore
new file mode 100644
index 00000000000..bf0327f3372
--- /dev/null
+++ b/searchlib/src/tests/prettyfloat/.gitignore
@@ -0,0 +1,4 @@
+.depend
+Makefile
+prettyfloat_test
+searchlib_prettyfloat_test_app
diff --git a/searchlib/src/tests/prettyfloat/CMakeLists.txt b/searchlib/src/tests/prettyfloat/CMakeLists.txt
new file mode 100644
index 00000000000..74e91518030
--- /dev/null
+++ b/searchlib/src/tests/prettyfloat/CMakeLists.txt
@@ -0,0 +1,8 @@
+# Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+vespa_add_executable(searchlib_prettyfloat_test_app
+ SOURCES
+ prettyfloat.cpp
+ DEPENDS
+ searchlib
+)
+vespa_add_test(NAME searchlib_prettyfloat_test_app COMMAND searchlib_prettyfloat_test_app)
diff --git a/searchlib/src/tests/prettyfloat/DESC b/searchlib/src/tests/prettyfloat/DESC
new file mode 100644
index 00000000000..fc4e85bcc09
--- /dev/null
+++ b/searchlib/src/tests/prettyfloat/DESC
@@ -0,0 +1 @@
+prettyfloat test. Take a look at prettyfloat.cpp for details.
diff --git a/searchlib/src/tests/prettyfloat/FILES b/searchlib/src/tests/prettyfloat/FILES
new file mode 100644
index 00000000000..fe3e151cf90
--- /dev/null
+++ b/searchlib/src/tests/prettyfloat/FILES
@@ -0,0 +1 @@
+prettyfloat.cpp
diff --git a/searchlib/src/tests/prettyfloat/prettyfloat.cpp b/searchlib/src/tests/prettyfloat/prettyfloat.cpp
new file mode 100644
index 00000000000..1ed9b7e1767
--- /dev/null
+++ b/searchlib/src/tests/prettyfloat/prettyfloat.cpp
@@ -0,0 +1,32 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#include <vespa/fastos/fastos.h>
+#include <vespa/log/log.h>
+LOG_SETUP("prettyfloat_test");
+#include <vespa/vespalib/testkit/testapp.h>
+#include <vespa/searchlib/util/rawbuf.h>
+#include <vespa/searchlib/common/hitrank.h>
+
+using namespace search;
+
+TEST_SETUP(Test);
+
+int
+Test::Main()
+{
+ TEST_INIT("prettyfloat_test");
+ {
+ RawBuf buf(5000);
+ SignedHitRank rank = 10;
+ buf.addSignedHitRank(rank);
+ *buf.GetWritableFillPos() = '\0';
+ EXPECT_EQUAL(std::string("10"), buf.GetDrainPos());
+ }
+ {
+ RawBuf buf(5000);
+ HitRank rank = 10;
+ buf.addHitRank(rank);
+ *buf.GetWritableFillPos() = '\0';
+ EXPECT_EQUAL(std::string("10"), buf.GetDrainPos());
+ }
+ TEST_DONE();
+}