commit 02f5bac3b8164ed0deb1f462bae91e2687b7409a
parent 8b7d3b5c2d9eb6996da5f3a355b3430671e18473
Author: Alexander Kojevnikov <alexander@kojevnikov.com>
Date: Mon, 4 Feb 2013 10:10:30 -0800
Move from lib to src
Diffstat:
19 files changed, 84 insertions(+), 67 deletions(-)
diff --git a/Makefile.am b/Makefile.am
@@ -1,9 +1,9 @@
SUBDIRS = \
data \
- lib \
man \
po \
- src
+ src \
+ tests
EXTRA_DIST = \
INSTALL.md \
diff --git a/configure.ac b/configure.ac
@@ -66,11 +66,11 @@ AC_CONFIG_FILES([
data/icons/scalable/Makefile
dist/osx/Info.plist
dist/win/spek.wxs
- lib/Makefile
man/Makefile
man/spek.1
po/Makefile.in
src/Makefile
+ tests/Makefile
web/version
])
AC_OUTPUT
diff --git a/dist/debian/copyright b/dist/debian/copyright
@@ -15,7 +15,7 @@ Copyright:
For everything not noted below:
Copyright (C) 2010-2012 Alexander Kojevnikov
- For lib/spek-pipeline.c:
+ For src/spek-pipeline.c:
Copyright (C) 2010-2012 Alexander Kojevnikov
Copyright (C) 2007-2009 Sebastian Dröge
Copyright (C) 2006 Stefan Kost
diff --git a/lib/Makefile.am b/lib/Makefile.am
@@ -1,20 +0,0 @@
-noinst_LIBRARIES = libspek.a
-
-libspek_a_SOURCES = \
- spek-audio.cc \
- spek-audio.h \
- spek-fft.cc \
- spek-fft.h \
- spek-palette.cc \
- spek-palette.h \
- spek-pipeline.cc \
- spek-pipeline.h \
- spek-utils.cc \
- spek-utils.h
-
-libspek_a_CPPFLAGS = \
- -include config.h \
- -pthread
-
-libspek_a_CXXFLAGS = \
- $(FFMPEG_CFLAGS)
diff --git a/src/Makefile.am b/src/Makefile.am
@@ -1,3 +1,24 @@
+noinst_LIBRARIES = libspek.a
+
+libspek_a_SOURCES = \
+ spek-audio.cc \
+ spek-audio.h \
+ spek-fft.cc \
+ spek-fft.h \
+ spek-palette.cc \
+ spek-palette.h \
+ spek-pipeline.cc \
+ spek-pipeline.h \
+ spek-utils.cc \
+ spek-utils.h
+
+libspek_a_CPPFLAGS = \
+ -include config.h \
+ -pthread
+
+libspek_a_CXXFLAGS = \
+ $(FFMPEG_CFLAGS)
+
bin_PROGRAMS = spek
spek_SOURCES = \
@@ -24,14 +45,13 @@ spek_SOURCES = \
spek_CPPFLAGS = \
-include config.h \
-pthread \
- -I$(top_srcdir)/lib \
$(WX_CPPFLAGS)
spek_CXXFLAGS = \
$(WX_CXXFLAGS_ONLY)
spek_LDADD = \
- ../lib/libspek.a \
+ libspek.a \
$(FFMPEG_LIBS) \
$(WX_LIBS)
diff --git a/lib/spek-audio.cc b/src/spek-audio.cc
diff --git a/lib/spek-audio.h b/src/spek-audio.h
diff --git a/lib/spek-fft.cc b/src/spek-fft.cc
diff --git a/lib/spek-fft.h b/src/spek-fft.h
diff --git a/lib/spek-palette.cc b/src/spek-palette.cc
diff --git a/lib/spek-palette.h b/src/spek-palette.h
diff --git a/lib/spek-pipeline.cc b/src/spek-pipeline.cc
diff --git a/lib/spek-pipeline.h b/src/spek-pipeline.h
diff --git a/lib/spek-utils.cc b/src/spek-utils.cc
diff --git a/lib/spek-utils.h b/src/spek-utils.h
diff --git a/tests/Makefile.am b/tests/Makefile.am
@@ -1,22 +1,22 @@
-TESTS = \
- test-utils \
- test
+TESTS = test
check_PROGRAMS = $(TESTS)
-noinst_HEADERS = \
+test_SOURCES = \
+ test-utils.cc \
+ test.cc \
test.h
AM_CPPFLAGS = \
-include config.h \
- -I$(top_srcdir)/lib \
+ -I$(top_srcdir)/src \
-pthread
-AM_CFLAGS = \
+AM_CXXFLAGS = \
$(FFMPEG_CFLAGS)
LDADD = \
- ../lib/libspek.a \
+ ../src/libspek.a \
$(FFMPEG_LIBS)
AM_LDFLAGS = \
diff --git a/tests/test-utils.cc b/tests/test-utils.cc
@@ -1,6 +1,6 @@
/* test-utils.cc
*
- * Copyright (C) 2012 Alexander Kojevnikov <alexander@kojevnikov.com>
+ * Copyright (C) 2012-2013 Alexander Kojevnikov <alexander@kojevnikov.com>
*
* Spek is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,25 +20,28 @@
#include "test.h"
-int main()
+void test_utils()
{
- ensure(0 == spek_vercmp("1.2.3", "1.2.3"), "1.2.3 == 1.2.3");
- ensure(1 == spek_vercmp("1.2.3", "1.2.2"), "1.2.3 > 1.2.2");
- ensure(-1 == spek_vercmp("1.2.2", "1.2.3"), "1.2.2 < 1.2.3");
- ensure(1 == spek_vercmp("1.2.3", "1"), "1.2.3 > 1");
- ensure(1 == spek_vercmp("1.2.3", "1."), "1.2.3 > 1.");
- ensure(1 == spek_vercmp("1.2.3", "1.2"), "1.2.3 > 1.2");
- ensure(1 == spek_vercmp("1.2.3", "1.2."), "1.2.3 > 1.2.");
- ensure(1 == spek_vercmp("1.15.3", "1.2"), "1.15.3 > 1.2");
- ensure(1 == spek_vercmp("2", "1.2.2"), "2 > 1.2.2");
- ensure(1 == spek_vercmp("1.2.3", ""), "1.2.3 > ''");
- ensure(0 == spek_vercmp("", ""), "'' == ''");
- ensure(0 == spek_vercmp("123", "123"), "123 == 123");
- ensure(-1 == spek_vercmp("0.2.3", "1"), "0.2.3 < 1");
- ensure(-1 == spek_vercmp("0.9.8", "0.10.1"), "0.9.8 < 0.10.1");
- ensure(-1 == spek_vercmp("1.200", "2.20"), "1.200 < 2.20");
- ensure(-1 == spek_vercmp("1.0.0", "2.0.0"), "1.0.0 < 2.0.0");
- ensure(-1 == spek_vercmp("1.0.0", "1.0.1"), "1.0.0 < 1.0.1");
+ test_vercmp();
+}
- return 0;
+static void test_vercmp()
+{
+ test(0 == spek_vercmp("1.2.3", "1.2.3"), "1.2.3 == 1.2.3");
+ test(1 == spek_vercmp("1.2.3", "1.2.2"), "1.2.3 > 1.2.2");
+ test(-1 == spek_vercmp("1.2.2", "1.2.3"), "1.2.2 < 1.2.3");
+ test(1 == spek_vercmp("1.2.3", "1"), "1.2.3 > 1");
+ test(1 == spek_vercmp("1.2.3", "1."), "1.2.3 > 1.");
+ test(1 == spek_vercmp("1.2.3", "1.2"), "1.2.3 > 1.2");
+ test(1 == spek_vercmp("1.2.3", "1.2."), "1.2.3 > 1.2.");
+ test(1 == spek_vercmp("1.15.3", "1.2"), "1.15.3 > 1.2");
+ test(1 == spek_vercmp("2", "1.2.2"), "2 > 1.2.2");
+ test(1 == spek_vercmp("1.2.3", ""), "1.2.3 > ''");
+ test(0 == spek_vercmp("", ""), "'' == ''");
+ test(0 == spek_vercmp("123", "123"), "123 == 123");
+ test(-1 == spek_vercmp("0.2.3", "1"), "0.2.3 < 1");
+ test(-1 == spek_vercmp("0.9.8", "0.10.1"), "0.9.8 < 0.10.1");
+ test(-1 == spek_vercmp("1.200", "2.20"), "1.200 < 2.20");
+ test(-1 == spek_vercmp("1.0.0", "2.0.0"), "1.0.0 < 2.0.0");
+ test(-1 == spek_vercmp("1.0.0", "1.0.1"), "1.0.0 < 1.0.1");
}
diff --git a/tests/test.cc b/tests/test.cc
@@ -1,6 +1,6 @@
/* test.cc
*
- * Copyright (C) 2012 Alexander Kojevnikov <alexander@kojevnikov.com>
+ * Copyright (C) 2012-2013 Alexander Kojevnikov <alexander@kojevnikov.com>
*
* Spek is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -16,11 +16,31 @@
* along with Spek. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <iostream>
+
#include "test.h"
+static int g_passes = 0;
+static int g_total = 0;
+
int main()
{
- ensure(2 + 2 == 4, "Hello, tests!");
+ test_utils();
- return 0;
+ std::cerr << g_passes << " / " << g_total << " test passed" << std::endl;
+ if (g_passes < g_total) {
+ return -1;
+ } else {
+ return 0;
+ }
+}
+
+void test(bool condition, const std::string& message)
+{
+ g_total++;
+ if (!condition) {
+ std::cerr << "FAIL: " << message << std::endl;
+ } else {
+ g_passes++;
+ }
}
diff --git a/tests/test.h b/tests/test.h
@@ -1,6 +1,6 @@
/* test.h
*
- * Copyright (C) 2012 Alexander Kojevnikov <alexander@kojevnikov.com>
+ * Copyright (C) 2012-2013 Alexander Kojevnikov <alexander@kojevnikov.com>
*
* Spek is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,16 +19,10 @@
#ifndef TEST_H_
#define TEST_H_
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
+#include <string>
-inline void ensure(bool test, const char *message)
-{
- if (!test) {
- printf("ERROR: %s\n", message);
- exit(1);
- }
-}
+void test(bool condition, const std::string& message);
+
+void test_utils();
#endif