[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r4011 - in trunk/pingus: src src/display src/input src/ping
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r4011 - in trunk/pingus: src src/display src/input src/pingus src/util test |
Date: |
Wed, 4 Nov 2009 06:20:28 +0100 |
Author: grumbel
Date: 2009-11-04 06:20:27 +0100 (Wed, 04 Nov 2009)
New Revision: 4011
Added:
trunk/pingus/test/evdev_device_test.cpp
trunk/pingus/test/line_iterator_test.cpp
trunk/pingus/test/memory_pool_test.cpp
trunk/pingus/test/rect_merger_test.cpp
trunk/pingus/test/utf8_test.cpp
Modified:
trunk/pingus/src/
trunk/pingus/src/display/rect_merger.cpp
trunk/pingus/src/input/evdev_device.cpp
trunk/pingus/src/pingus/line_iterator.cpp
trunk/pingus/src/pingus/pingus_level.hpp
trunk/pingus/src/util/utf8.cpp
Log:
Moved tests from source tree to test/ directory
Property changes on: trunk/pingus/src
___________________________________________________________________
Name: svn:ignore
-
*.a
aclocal.m4
autom4te.cache
config.guess
config.h
config.h.in
config.log
config.status
config.sub
configure
depcomp
.deps
*.gmo
line_iterator
Makefile
Makefile.in
missing
*.o
old
old/
pingus
pingus_level_test
.sconsign
semantic.cache
stamp-h1
xmleval
+ *.a
aclocal.m4
autom4te.cache
config.guess
config.h
config.h.in
config.log
config.status
config.sub
configure
depcomp
.deps
*.gmo
line_iterator
Makefile
Makefile.in
missing
*.o
old
old/
pingus
pingus_level_test
.sconsign
semantic.cache
stamp-h1
xmleval
Modified: trunk/pingus/src/display/rect_merger.cpp
===================================================================
--- trunk/pingus/src/display/rect_merger.cpp 2009-11-04 02:14:11 UTC (rev
4010)
+++ trunk/pingus/src/display/rect_merger.cpp 2009-11-04 05:20:27 UTC (rev
4011)
@@ -300,122 +300,6 @@
//print_rects(std::cerr, rects_out);
}
-#ifdef __TEST__
-
-// g++ -Wall -O2 -D__TEST__ rect_merger.cpp ../math/rect.cpp
../math/origin.cpp -o rect_merger
-
-#include <stdlib.h>
-
-int main(int argc, char** argv)
-{
- int t = 1216020230; // 20
- //1216032809 // 20
- //int t = time(NULL);
- //int t = 1216035347;
-
- srand(t);
-
- std::cerr << t << std::endl;
-
- std::vector<Rect> rects_in;
- std::vector<Rect> rects_out;
-
- // Generate random rectangles
- if (0)
- for(int i = 0; i < 400; ++i)
- {
- rects_in.push_back(Rect(Vector2i(rand() % 800,
- rand() % 800),
- Size(rand() % 60 + 10,
- rand() % 60 + 10)));
- }
-
- rects_in.push_back(Rect(380, 279, 412, 311));
- rects_in.push_back(Rect(307, 280, 339, 312));
- rects_in.push_back(Rect(397, 279, 429, 311));
- rects_in.push_back(Rect(354, 280, 386, 312));
- rects_in.push_back(Rect(282, 277, 314, 309));
- rects_in.push_back(Rect(441, 282, 473, 314));
- rects_in.push_back(Rect(531, 281, 563, 313));
- rects_in.push_back(Rect(249, 280, 281, 312));
- rects_in.push_back(Rect(4, 112, 36, 144));
- rects_in.push_back(Rect(381, 279, 413, 311));
- rects_in.push_back(Rect(306, 280, 338, 312));
- rects_in.push_back(Rect(396, 279, 428, 311));
- rects_in.push_back(Rect(355, 280, 387, 312));
- rects_in.push_back(Rect(283, 277, 315, 309));
- rects_in.push_back(Rect(440, 282, 472, 314));
- rects_in.push_back(Rect(530, 281, 562, 313));
- rects_in.push_back(Rect(249, 280, 281, 312));
- rects_in.push_back(Rect(4, 112, 36, 144));
-
- merge_rectangles(rects_in, rects_out);
-
- if (1) // print results as SVG
- {
- std::cout << "<?xml version='1.0' standalone='no'?>\n"
- << "<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' "
- << "'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'>\n"
- << "<svg width='800' height='800' "
- << "xmlns='http://www.w3.org/2000/svg' version='1.1'>" <<
std::endl;
-
- std::cout << "<g>" << std::endl;
- for(std::vector<Rect>::iterator i = rects_in.begin(); i !=
rects_in.end(); ++i)
- std::cout << " <rect fill='blue' style='fill-opacity:0.5' x='" <<
i->left << "' y='" << i->top
- << "' width='" << i->get_width() << "' height='" <<
i->get_height() << "' />" << std::endl;
- std::cout << "</g>" << std::endl;
- std::cout << std::endl;
-
- std::cout << "<g>" << std::endl;
- for(std::vector<Rect>::iterator i = rects_out.begin(); i !=
rects_out.end(); ++i)
- std::cout << " <rect fill='yellow' stroke='black'
style='fill-opacity:0.5;stroke-width:1px' x='" << i->left << "' y='" << i->top
- << "' width='" << i->get_width() << "' height='" <<
i->get_height() << "' />" << std::endl;
- std::cout << "</g>" << std::endl;
- std::cout << "</svg>" << std::endl;
- }
-
- return 0;
-}
-
-/*
-
- if (1)
- {
- std::cout << "--- Merge rectangles: " << rects_in.size() << std::endl;
- for(std::vector<Rect>::const_iterator i = rects_in.begin(); i !=
rects_in.end(); ++i)
- {
- std::cout << " rectin: " << *i << std::endl;
- }
- }
-
- for(std::vector<Row>::const_iterator i = rows.begin(); i != rows.end(); ++i)
- {
- std::cout << "Row: " << i->marks.size() << " ";
- for(std::vector<Mark>::const_iterator j = i->marks.begin(); j !=
i->marks.end(); ++j)
- {
- std::cout << ((j->type == Mark::START_MARK) ? "'(" : "')")
- << j->pos
- << "' ";
- }
- std::cout << std::endl;
- }
-
- // Print rows
- if (0)
- for(std::vector<Row>::iterator i = rows.begin(); i != rows.end(); ++i)
- {
- std::cout << " row: " << i->top << "-" << i->bottom << " - ";
- for(std::vector<Mark>::iterator mark_it = i->marks.begin(); mark_it !=
i->marks.end(); ++mark_it)
- {
- std::cout << ((mark_it->type == Mark::START_MARK) ? "'(" : "')")
- << mark_it->pos
- << "' ";
- }
- std::cout << std::endl;
- }
-
- */
-
#endif
/* EOF */
Modified: trunk/pingus/src/input/evdev_device.cpp
===================================================================
--- trunk/pingus/src/input/evdev_device.cpp 2009-11-04 02:14:11 UTC (rev
4010)
+++ trunk/pingus/src/input/evdev_device.cpp 2009-11-04 05:20:27 UTC (rev
4011)
@@ -321,27 +321,4 @@
} // namespace Input
-#ifdef __TEST__
-// g++ -D__TEST__ evdev_device.cpp -o evdev -Wall -Werror
-int main(int argc, char** argv)
-{
- if (argc != 2)
- {
- std::cout << "Usage: evdev FILENAME" << std::endl;
- }
- else
- {
- std::cout << "EvdevDevice: " << argv[1] << std::endl;
-
- Input::EvdevDevice dev(argv[1]);
- while(true)
- {
- dev.update(0.0f);
- }
- }
- return 0;
-}
-
-#endif
-
/* EOF */
Modified: trunk/pingus/src/pingus/line_iterator.cpp
===================================================================
--- trunk/pingus/src/pingus/line_iterator.cpp 2009-11-04 02:14:11 UTC (rev
4010)
+++ trunk/pingus/src/pingus/line_iterator.cpp 2009-11-04 05:20:27 UTC (rev
4011)
@@ -57,36 +57,4 @@
return std::string(first, line_end);
}
-#ifdef __TEST__
-// g++ line_iterator.cpp -o line_iterator -D__TEST__ -Wall -Werror -ansi
-pedantic
-#include <iostream>
-
-void test(const std::string& str)
-{
- std::cout << "Testing: " << std::endl;
- std::cout << "in: \"" << str << "\"" << std::endl;
-
- std::cout << "out: " << std::flush;
-
- LineIterator it(str);
- while(it.next())
- std::cout << "\"" << it.get() << "\" " << std::flush;
-
- std::cout << std::endl;
- std::cout << std::endl;
-}
-
-int main()
-{
- test("Test One");
- test("Test\nTwo");
- test("\nHello\nThree");
- test("Hello Four\n");
- test("Hello\nWorld\nFooBar\n");
- test("Hello\nWorld\nFooBar\n\n");
- test("1");
- return 0;
-}
-#endif
-
/* EOF */
Modified: trunk/pingus/src/pingus/pingus_level.hpp
===================================================================
--- trunk/pingus/src/pingus/pingus_level.hpp 2009-11-04 02:14:11 UTC (rev
4010)
+++ trunk/pingus/src/pingus/pingus_level.hpp 2009-11-04 05:20:27 UTC (rev
4011)
@@ -1,4 +1,4 @@
- // Pingus - A free Lemmings clone
+// Pingus - A free Lemmings clone
// Copyright (C) 2002 Ingo Ruhnke <address@hidden>
//
// This program is free software: you can redistribute it and/or modify
Modified: trunk/pingus/src/util/utf8.cpp
===================================================================
--- trunk/pingus/src/util/utf8.cpp 2009-11-04 02:14:11 UTC (rev 4010)
+++ trunk/pingus/src/util/utf8.cpp 2009-11-04 05:20:27 UTC (rev 4011)
@@ -21,7 +21,7 @@
/** Replacement character for invalid UTF-8 sequences */
static const uint32_t INVALID_UTF8_SEQUENCE = 0xFFFD;
-
+
bool
UTF8::is_linebreak_character(uint32_t unicode)
{
@@ -231,24 +231,5 @@
{
return chr;
}
-
-#ifdef __TEST__
-int main(int argc, char** argv)
-{
- if (argc != 2)
- {
- std::cout << "Usage: " << argv[0] << " TEXT" << std::endl;
- }
- else
- {
- std::cout << "ASCII: " << std::string(argv[1]).length() << std::endl;
- std::cout << "UTF8: " << UTF8::length(argv[1]) << std::endl;
- std::string res = UTF8::substr(argv[1], 1, 1);
- std::cout << "substr: " << res.length() << " " << res << std::endl;
- }
- return 0;
-}
-#endif
-
/* EOF */
Added: trunk/pingus/test/evdev_device_test.cpp
===================================================================
--- trunk/pingus/test/evdev_device_test.cpp 2009-11-04 02:14:11 UTC (rev
4010)
+++ trunk/pingus/test/evdev_device_test.cpp 2009-11-04 05:20:27 UTC (rev
4011)
@@ -0,0 +1,40 @@
+// Pingus - A free Lemmings clone
+// Copyright (C) 1998-2009 Ingo Ruhnke <address@hidden>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU 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 General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#include "evdev_device_test.hpp"
+
+// g++ -D__TEST__ evdev_device.cpp -o evdev -Wall -Werror
+
+int main(int argc, char** argv)
+{
+ if (argc != 2)
+ {
+ std::cout << "Usage: evdev FILENAME" << std::endl;
+ }
+ else
+ {
+ std::cout << "EvdevDevice: " << argv[1] << std::endl;
+
+ Input::EvdevDevice dev(argv[1]);
+ while(true)
+ {
+ dev.update(0.0f);
+ }
+ }
+ return 0;
+}
+
+/* EOF */
Property changes on: trunk/pingus/test/evdev_device_test.cpp
___________________________________________________________________
Name: svn:eol-style
+ native
Added: trunk/pingus/test/line_iterator_test.cpp
===================================================================
--- trunk/pingus/test/line_iterator_test.cpp 2009-11-04 02:14:11 UTC (rev
4010)
+++ trunk/pingus/test/line_iterator_test.cpp 2009-11-04 05:20:27 UTC (rev
4011)
@@ -0,0 +1,50 @@
+// Pingus - A free Lemmings clone
+// Copyright (C) 1998-2009 Ingo Ruhnke <address@hidden>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU 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 General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#include "line_iterator_test.hpp"
+
+// g++ line_iterator.cpp -o line_iterator -D__TEST__ -Wall -Werror -ansi
-pedantic
+
+#include <iostream>
+
+void test(const std::string& str)
+{
+ std::cout << "Testing: " << std::endl;
+ std::cout << "in: \"" << str << "\"" << std::endl;
+
+ std::cout << "out: " << std::flush;
+
+ LineIterator it(str);
+ while(it.next())
+ std::cout << "\"" << it.get() << "\" " << std::flush;
+
+ std::cout << std::endl;
+ std::cout << std::endl;
+}
+
+int main()
+{
+ test("Test One");
+ test("Test\nTwo");
+ test("\nHello\nThree");
+ test("Hello Four\n");
+ test("Hello\nWorld\nFooBar\n");
+ test("Hello\nWorld\nFooBar\n\n");
+ test("1");
+ return 0;
+}
+
+/* EOF */
Property changes on: trunk/pingus/test/line_iterator_test.cpp
___________________________________________________________________
Name: svn:eol-style
+ native
Added: trunk/pingus/test/memory_pool_test.cpp
===================================================================
--- trunk/pingus/test/memory_pool_test.cpp 2009-11-04 02:14:11 UTC (rev
4010)
+++ trunk/pingus/test/memory_pool_test.cpp 2009-11-04 05:20:27 UTC (rev
4011)
@@ -0,0 +1,46 @@
+// Pingus - A free Lemmings clone
+// Copyright (C) 1998-2009 Ingo Ruhnke <address@hidden>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU 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 General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#include "memory_pool_test.hpp"
+
+// g++ -Wall -Werror -ansi -pedantic -O2 -g memory_pool_test.cpp -o
memory_pool_test
+
+#include <iostream>
+#include "memory_pool.hpp"
+
+struct Thing {
+ int i;
+
+ Thing(int i_) : i(i_) {
+ std::cout << "Constructing thing: " << i << std::endl;
+ }
+
+ ~Thing() {
+ std::cout << "Destructing thing: " << i << std::endl;
+ }
+};
+
+int main()
+{
+ MemoryPool<Thing> pool;
+ pool.create<Thing>(5);
+ pool.create<Thing>(3);
+ pool.create<Thing>(2);
+
+ return 0;
+}
+
+/* EOF */
Property changes on: trunk/pingus/test/memory_pool_test.cpp
___________________________________________________________________
Name: svn:eol-style
+ native
Added: trunk/pingus/test/rect_merger_test.cpp
===================================================================
--- trunk/pingus/test/rect_merger_test.cpp 2009-11-04 02:14:11 UTC (rev
4010)
+++ trunk/pingus/test/rect_merger_test.cpp 2009-11-04 05:20:27 UTC (rev
4011)
@@ -0,0 +1,133 @@
+// Pingus - A free Lemmings clone
+// Copyright (C) 1998-2009 Ingo Ruhnke <address@hidden>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU 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 General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#include "rect_merger_test.hpp"
+
+// g++ -Wall -O2 -D__TEST__ rect_merger.cpp ../math/rect.cpp
../math/origin.cpp -o rect_merger
+
+#include <stdlib.h>
+
+int main(int argc, char** argv)
+{
+ int t = 1216020230; // 20
+ //1216032809 // 20
+ //int t = time(NULL);
+ //int t = 1216035347;
+
+ srand(t);
+
+ std::cerr << t << std::endl;
+
+ std::vector<Rect> rects_in;
+ std::vector<Rect> rects_out;
+
+ // Generate random rectangles
+ if (0)
+ for(int i = 0; i < 400; ++i)
+ {
+ rects_in.push_back(Rect(Vector2i(rand() % 800,
+ rand() % 800),
+ Size(rand() % 60 + 10,
+ rand() % 60 + 10)));
+ }
+
+ rects_in.push_back(Rect(380, 279, 412, 311));
+ rects_in.push_back(Rect(307, 280, 339, 312));
+ rects_in.push_back(Rect(397, 279, 429, 311));
+ rects_in.push_back(Rect(354, 280, 386, 312));
+ rects_in.push_back(Rect(282, 277, 314, 309));
+ rects_in.push_back(Rect(441, 282, 473, 314));
+ rects_in.push_back(Rect(531, 281, 563, 313));
+ rects_in.push_back(Rect(249, 280, 281, 312));
+ rects_in.push_back(Rect(4, 112, 36, 144));
+ rects_in.push_back(Rect(381, 279, 413, 311));
+ rects_in.push_back(Rect(306, 280, 338, 312));
+ rects_in.push_back(Rect(396, 279, 428, 311));
+ rects_in.push_back(Rect(355, 280, 387, 312));
+ rects_in.push_back(Rect(283, 277, 315, 309));
+ rects_in.push_back(Rect(440, 282, 472, 314));
+ rects_in.push_back(Rect(530, 281, 562, 313));
+ rects_in.push_back(Rect(249, 280, 281, 312));
+ rects_in.push_back(Rect(4, 112, 36, 144));
+
+ merge_rectangles(rects_in, rects_out);
+
+ if (1) // print results as SVG
+ {
+ std::cout << "<?xml version='1.0' standalone='no'?>\n"
+ << "<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' "
+ << "'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'>\n"
+ << "<svg width='800' height='800' "
+ << "xmlns='http://www.w3.org/2000/svg' version='1.1'>" <<
std::endl;
+
+ std::cout << "<g>" << std::endl;
+ for(std::vector<Rect>::iterator i = rects_in.begin(); i !=
rects_in.end(); ++i)
+ std::cout << " <rect fill='blue' style='fill-opacity:0.5' x='" <<
i->left << "' y='" << i->top
+ << "' width='" << i->get_width() << "' height='" <<
i->get_height() << "' />" << std::endl;
+ std::cout << "</g>" << std::endl;
+ std::cout << std::endl;
+
+ std::cout << "<g>" << std::endl;
+ for(std::vector<Rect>::iterator i = rects_out.begin(); i !=
rects_out.end(); ++i)
+ std::cout << " <rect fill='yellow' stroke='black'
style='fill-opacity:0.5;stroke-width:1px' x='" << i->left << "' y='" << i->top
+ << "' width='" << i->get_width() << "' height='" <<
i->get_height() << "' />" << std::endl;
+ std::cout << "</g>" << std::endl;
+ std::cout << "</svg>" << std::endl;
+ }
+
+ return 0;
+}
+
+/*
+
+ if (1)
+ {
+ std::cout << "--- Merge rectangles: " << rects_in.size() << std::endl;
+ for(std::vector<Rect>::const_iterator i = rects_in.begin(); i !=
rects_in.end(); ++i)
+ {
+ std::cout << " rectin: " << *i << std::endl;
+ }
+ }
+
+ for(std::vector<Row>::const_iterator i = rows.begin(); i != rows.end(); ++i)
+ {
+ std::cout << "Row: " << i->marks.size() << " ";
+ for(std::vector<Mark>::const_iterator j = i->marks.begin(); j !=
i->marks.end(); ++j)
+ {
+ std::cout << ((j->type == Mark::START_MARK) ? "'(" : "')")
+ << j->pos
+ << "' ";
+ }
+ std::cout << std::endl;
+ }
+
+ // Print rows
+ if (0)
+ for(std::vector<Row>::iterator i = rows.begin(); i != rows.end(); ++i)
+ {
+ std::cout << " row: " << i->top << "-" << i->bottom << " - ";
+ for(std::vector<Mark>::iterator mark_it = i->marks.begin(); mark_it !=
i->marks.end(); ++mark_it)
+ {
+ std::cout << ((mark_it->type == Mark::START_MARK) ? "'(" : "')")
+ << mark_it->pos
+ << "' ";
+ }
+ std::cout << std::endl;
+ }
+
+ */
+
+/* EOF */
Property changes on: trunk/pingus/test/rect_merger_test.cpp
___________________________________________________________________
Name: svn:eol-style
+ native
Added: trunk/pingus/test/utf8_test.cpp
===================================================================
--- trunk/pingus/test/utf8_test.cpp 2009-11-04 02:14:11 UTC (rev 4010)
+++ trunk/pingus/test/utf8_test.cpp 2009-11-04 05:20:27 UTC (rev 4011)
@@ -0,0 +1,36 @@
+// Pingus - A free Lemmings clone
+// Copyright (C) 1998-2009 Ingo Ruhnke <address@hidden>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU 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 General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#include "utf8_test.hpp"
+
+int main(int argc, char** argv)
+{
+ if (argc != 2)
+ {
+ std::cout << "Usage: " << argv[0] << " TEXT" << std::endl;
+ }
+ else
+ {
+ std::cout << "ASCII: " << std::string(argv[1]).length() << std::endl;
+ std::cout << "UTF8: " << UTF8::length(argv[1]) << std::endl;
+
+ std::string res = UTF8::substr(argv[1], 1, 1);
+ std::cout << "substr: " << res.length() << " " << res << std::endl;
+ }
+ return 0;
+}
+
+/* EOF */
Property changes on: trunk/pingus/test/utf8_test.cpp
___________________________________________________________________
Name: svn:eol-style
+ native
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r4011 - in trunk/pingus: src src/display src/input src/pingus src/util test,
grumbel at BerliOS <=