[med-svn] [libgtextutils] 29/83: Added test suite and bumped version to 0.2.
Charles Plessy
plessy at moszumanska.debian.org
Wed Jan 8 13:37:27 UTC 2014
This is an automated email from the git hooks/post-receive script.
plessy pushed a commit to branch debian/unstable
in repository libgtextutils.
commit 496eb071b7a87bfa6e519516f70568181ef936c8
Author: A. Gordon <gordon at cshl.edu>
Date: Tue Mar 24 20:36:04 2009 -0400
Added test suite and bumped version to 0.2.
---
Makefile.am | 4 +-
configure.ac | 5 +-
gtextutils-0.1.pc.in => gtextutils-0.2.pc.in | 4 +-
Makefile.am => tests/Makefile.am | 15 +++--
tests/test_container_join.cpp | 75 ++++++++++++++++++++++
.../print_utils.h => tests/test_natural_sort.cpp | 56 +++++++++-------
6 files changed, 127 insertions(+), 32 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 41047b2..6e40be1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -9,7 +9,7 @@
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
EXTRA_DIST = reconf configure
-SUBDIRS = m4 src doc
+SUBDIRS = m4 src doc tests
pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = gtextutils-0.1.pc
+pkgconfig_DATA = gtextutils-0.2.pc
diff --git a/configure.ac b/configure.ac
index 9b5cedb..d0ad004 100644
--- a/configure.ac
+++ b/configure.ac
@@ -9,7 +9,7 @@
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
AC_INIT([Gordon-Text_utils-Library],
- [0.1],
+ [0.2],
[A. Gordon gordon at cshl.edu],
[libgtextutils])
AC_CONFIG_AUX_DIR(config)
@@ -67,7 +67,8 @@ AC_CONFIG_FILES([
m4/Makefile
src/Makefile
src/gtextutils/Makefile
- gtextutils-0.1.pc
+ gtextutils-0.2.pc
+ tests/Makefile
])
AC_OUTPUT
diff --git a/gtextutils-0.1.pc.in b/gtextutils-0.2.pc.in
similarity index 68%
rename from gtextutils-0.1.pc.in
rename to gtextutils-0.2.pc.in
index 59f2579..eceed2b 100644
--- a/gtextutils-0.1.pc.in
+++ b/gtextutils-0.2.pc.in
@@ -6,5 +6,5 @@ includedir=@includedir@
Name: gtextutils
Description: Gordon's text-utility classes
Version: @VERSION@
-Libs: -L${libdir} -lgtextutils-0.1
-Cflags: -I${includedir}/gtextutils-0.1
+Libs: -L${libdir} -lgtextutils-0.2
+Cflags: -I${includedir}/gtextutils-0.2
diff --git a/Makefile.am b/tests/Makefile.am
similarity index 62%
copy from Makefile.am
copy to tests/Makefile.am
index 41047b2..61876a5 100644
--- a/Makefile.am
+++ b/tests/Makefile.am
@@ -8,8 +8,15 @@
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-EXTRA_DIST = reconf configure
-SUBDIRS = m4 src doc
-pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = gtextutils-0.1.pc
+
+check_PROGRAMS = test_container_join \
+ test_natural_sort
+
+TESTS = $(check_PROGRAMS)
+
+LDADD = $(top_srcdir)/src/gtextutils/libgtextutils-$(VERSION).a
+INCLUDES = -I$(top_srcdir)/src
+
+test_container_join_SOURCES = test_container_join.cpp
+test_natural_sort_SOURCES = test_natural_sort.cpp
diff --git a/tests/test_container_join.cpp b/tests/test_container_join.cpp
new file mode 100644
index 0000000..b413326
--- /dev/null
+++ b/tests/test_container_join.cpp
@@ -0,0 +1,75 @@
+/*
+ Gordon's Text-Utilities Library
+ Copyright (C) 2009 Assaf Gordon (gordon at cshl.edu)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>
+*/
+#include <vector>
+#include <map>
+#include <string>
+#include <iostream>
+
+#include <gtextutils/container_join.h>
+
+/*
+ * Tiny test suite for container-join templates
+ */
+
+using namespace std;
+
+int main()
+{
+ vector<int> v;
+ for (int i=0;i<10;++i)
+ v.push_back(i);
+
+ // Print the entire container:
+ cout << join(v,",") << endl;
+ // Will output: 0,1,2,3,4,5,6,7,8,9
+
+ // Print specific range, using begin/end iterators
+ cout << join(v.begin(), v.end(),"-") << endl;
+ // Will output: 0-1-2-3-4-5-6-7-8-9
+
+ // An std::pair<> based container
+ // map/set/multimap/multiset/unorederd_map etc.
+ // or
+ // vector< pair<A,B> > etc.
+ map<int, string> m;
+ m[42] = "Don't Panic";
+ m[666]= "Beast" ;
+
+ // Print the first values (of the pair) of the entire container:
+ cout << "keys = " << join_firsts(m) << endl;
+ // Will output: 42 <tab> 666
+
+ // Print the first values (of the pair) of a specific range:
+ cout << "keys = " << join_firsts(m.begin(), m.end(), ",") << endl;
+ // Will output: 42,666
+
+ // Print the second values (of the pair) of the entire container:
+ cout << "values= " << join_seconds(m) << endl;
+ // Will output: Don't Panic<tab>Beast
+
+ // Print the second values (of the pair) of a specific range:
+ cout << "values= " << join_seconds(m.begin(), m.end(), ",") << endl;
+ // Will output: Don't Panic,Beast
+
+
+ // Store result in a string (instead of an output stream):
+ string s = join_firsts(m);
+ // 's' will contain: "42\t666";
+
+ return 0;
+}
diff --git a/src/gtextutils/print_utils.h b/tests/test_natural_sort.cpp
similarity index 51%
rename from src/gtextutils/print_utils.h
rename to tests/test_natural_sort.cpp
index 7a041fd..99af61b 100644
--- a/src/gtextutils/print_utils.h
+++ b/tests/test_natural_sort.cpp
@@ -15,33 +15,45 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
-#ifndef __PRINT_UTILS_H__
-#define __PRINT_UTILS_H__
-
+#include <vector>
#include <string>
-#include <sstream>
+#include <iostream>
+
+#include <gtextutils/container_join.h>
+
+#include <gtextutils/natsort.h>
+
+/*
+ * Tiny test suite for natural sort
+ */
+
+using namespace std;
-template<class COLLECTION>
-inline
-std::string
-join_collection(const COLLECTION &col, const std::string& delimiter="\t")
+int main()
{
- std::ostringstream os;
- bool first = true ;
+ vector<string> v;
- typename COLLECTION::const_iterator it = col.begin();
+ v.push_back("chr4");
+ v.push_back("chr2");
+ v.push_back("chr10");
+ v.push_back("chr11");
+ v.push_back("chr1");
+ v.push_back("chrX");
+ v.push_back("chr20");
+ v.push_back("ChR13");
- while ( it != col.end() ) {
- if ( first )
- first = false;
- else
- os << delimiter ;
- os << *it ;
- it++ ;
- }
+ sort(v.begin(), v.end());
- return os.str();
-}
+ cout << "Regular sort: " << join(v) << endl;
+
+ sort(v.begin(), v.end(), natural_sort_predicate() );
+ cout << "Natural sort (case sensitive): " << join(v) << endl;
+
+ sort(v.begin(), v.end(), natural_sort_ignore_case_predicate() );
+ cout << "Natural sort (case-insensitive): " << join(v) << endl;
-#endif
+
+
+ return 0;
+}
--
Alioth's /git/debian-med/git-commit-notice on /srv/git.debian.org/git/debian-med/libgtextutils.git
More information about the debian-med-commit
mailing list