summaryrefslogtreecommitdiff
path: root/fast/test
diff options
context:
space:
mode:
Diffstat (limited to 'fast/test')
-rw-r--r--fast/test/Makefile16
-rwxr-xr-xfast/test/test_grammarbin0 -> 56832 bytes
-rw-r--r--fast/test/test_grammar.cc20
-rwxr-xr-xfast/test/test_sparse_vectorbin0 -> 44288 bytes
-rw-r--r--fast/test/test_sparse_vector.cc37
5 files changed, 73 insertions, 0 deletions
diff --git a/fast/test/Makefile b/fast/test/Makefile
new file mode 100644
index 0000000..0140f63
--- /dev/null
+++ b/fast/test/Makefile
@@ -0,0 +1,16 @@
+COMPILER=g++
+CFLAGS=-std=c++11 -O3 -I../
+TCMALLOC=/home/pks/src/weaver/fast/gperftools-2.1/lib/libtcmalloc_minimal.a -pthread
+
+
+all: test_grammar test_sparse_vector
+
+test_grammar: test_grammar.cc ../grammar.hh
+ $(COMPILER) $(CFLAGS) -lstdc++ -lm $(TCMALLOC) test_grammar.cc -o test_grammar
+
+test_sparse_vector: test_sparse_vector.cc ../sparse_vector.hh
+ $(COMPILER) $(CFLAGS) -lstdc++ -lm $(TCMALLOC) test_sparse_vector.cc -o test_sparse_vector
+
+clean:
+ rm -f test_grammar test_sparse_vector
+
diff --git a/fast/test/test_grammar b/fast/test/test_grammar
new file mode 100755
index 0000000..088d55a
--- /dev/null
+++ b/fast/test/test_grammar
Binary files differ
diff --git a/fast/test/test_grammar.cc b/fast/test/test_grammar.cc
new file mode 100644
index 0000000..bbe76e7
--- /dev/null
+++ b/fast/test/test_grammar.cc
@@ -0,0 +1,20 @@
+#include <fstream>
+
+#include "grammar.hh"
+
+using namespace std;
+
+
+int
+main(int argc, char** argv)
+{
+ G::Vocabulary y;
+ G::Grammar g(argv[1], y);
+ for (auto it: g.rules) {
+ it->escaped(cout);
+ cout << endl;
+ }
+
+ return 0;
+}
+
diff --git a/fast/test/test_sparse_vector b/fast/test/test_sparse_vector
new file mode 100755
index 0000000..c06fe9e
--- /dev/null
+++ b/fast/test/test_sparse_vector
Binary files differ
diff --git a/fast/test/test_sparse_vector.cc b/fast/test/test_sparse_vector.cc
new file mode 100644
index 0000000..426bed1
--- /dev/null
+++ b/fast/test/test_sparse_vector.cc
@@ -0,0 +1,37 @@
+#include "sparse_vector.hh"
+
+
+int
+main(void)
+{
+ Sv::SparseVector<string, score_t> a;
+ a.insert("1", 1);
+ a.insert("2", 2);
+ cout << "a:" << a << endl;
+
+ Sv::SparseVector<string, score_t> b;
+ b.insert("2", 2);
+ cout << "b:" << b << endl;
+
+ Sv::SparseVector<string, score_t> c = a + b;
+ cout << "a+b:" << c << endl;
+
+ a += b;
+ cout << "a+=b:" << a << endl;
+
+ a -= b;
+ cout << "a-=b:" << a << endl;
+
+ cout << "a*2:" << a*2 << endl;
+
+ a *= 2;
+ cout << "a*=2:" << a << endl;
+
+ string s("\"a\"=2 \"b\"=3");
+ Sv::SparseVector<string, score_t>* sv = new Sv::SparseVector<string, score_t>(s);
+ cout << *sv << endl;
+ cout << sv->dot(*sv) << endl;
+
+ return 0;
+}
+