summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2009-07-07 04:23:13 +0000
committerTavian Barnes <tavianator@gmail.com>2009-07-07 04:23:13 +0000
commit14c9cd86e1b7c6ff27c5000d72721c54a718daac (patch)
tree4c8bc80066d8a495c01258bab7457e031de0a22e /tests
parent81c84a38992ce8e38106d86ce85ac3e88ed91a31 (diff)
downloaddimension-14c9cd86e1b7c6ff27c5000d72721c54a718daac.tar.xz
New 'Dimension::Tests' namespace for libdimensionxx-tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/glxx.cpp4
-rw-r--r--tests/raytracexx.cpp2
-rw-r--r--tests/testsxx.cpp83
-rw-r--r--tests/testsxx.hpp31
4 files changed, 63 insertions, 57 deletions
diff --git a/tests/glxx.cpp b/tests/glxx.cpp
index aaf7b7b..d88c27d 100644
--- a/tests/glxx.cpp
+++ b/tests/glxx.cpp
@@ -26,7 +26,7 @@ int
main() {
using namespace Dimension;
- Scene scene = default_scene();
+ Scene scene = Tests::default_scene();
Perspective_Camera& camera
= dynamic_cast<Perspective_Camera&>(scene.camera());
@@ -47,7 +47,7 @@ main() {
Raytracer raytracer(scene);
GL_Drawer drawer(scene.canvas());
- Dimension::Display display(scene.canvas());
+ Tests::Display display(scene.canvas());
// Render the scene
for (unsigned int i = 0; i < 10; ++i) {
diff --git a/tests/raytracexx.cpp b/tests/raytracexx.cpp
index 4202347..3fed923 100644
--- a/tests/raytracexx.cpp
+++ b/tests/raytracexx.cpp
@@ -28,7 +28,7 @@ main() {
// Set the resilience low for tests
resilience(SEVERITY_LOW);
- Scene scene = default_scene();
+ Scene scene = Tests::default_scene();
// Render the scene
{
diff --git a/tests/testsxx.cpp b/tests/testsxx.cpp
index 399e50f..f0d5646 100644
--- a/tests/testsxx.cpp
+++ b/tests/testsxx.cpp
@@ -21,58 +21,61 @@
namespace Dimension
{
- Scene
- default_scene()
+ namespace Tests
{
- // Background color
- Color background = sRGB(0.0, 0.1, 0.25);
- background.filter(0.1);
+ Scene
+ default_scene()
+ {
+ // Background color
+ Color background = sRGB(0.0, 0.1, 0.25);
+ background.filter(0.1);
- // Canvas
- Canvas canvas(768, 480);
+ // Canvas
+ Canvas canvas(768, 480);
- // Camera
- Perspective_Camera camera(
- Matrix::rotation(Vector(0.0, 1.0, 0.0))
- * Matrix::translation(Vector(0.0, 0.0, -4.0))
- * Matrix::scale(
- Vector(static_cast<double>(canvas.width())/canvas.height(), 1.0, 1.0)
- )
- );
+ // Camera
+ Perspective_Camera camera(
+ Matrix::rotation(Vector(0.0, 1.0, 0.0))
+ * Matrix::translation(Vector(0.0, 0.0, -4.0))
+ * Matrix::scale(
+ Vector(static_cast<double>(canvas.width())/canvas.height(), 1.0, 1.0)
+ )
+ );
- // Scene
- Scene scene(background, camera, canvas);
+ // Scene
+ Scene scene(background, camera, canvas);
- // Objects in scene
+ // Objects in scene
- Sphere sphere;
- sphere.trans(inverse(Matrix::scale(Vector(1.25, 1.25, 1.25))));
- scene.push_object(sphere);
+ Sphere sphere;
+ sphere.trans(inverse(Matrix::scale(Vector(1.25, 1.25, 1.25))));
+ scene.push_object(sphere);
- Cube cube;
- cube.trans(inverse(Matrix::rotation(Vector(0.75, 0.0, 0.0))));
- scene.push_object(cube);
+ Cube cube;
+ cube.trans(inverse(Matrix::rotation(Vector(0.75, 0.0, 0.0))));
+ scene.push_object(cube);
- return scene;
- }
+ return scene;
+ }
- Display::Display(const Canvas& canvas)
- : m_display(dmnsn_new_display(canvas.dmnsn()))
- {
- if (!m_display) {
- throw Dimension_Error("Couldn't create display.");
+ Display::Display(const Canvas& canvas)
+ : m_display(dmnsn_new_display(canvas.dmnsn()))
+ {
+ if (!m_display) {
+ throw Dimension_Error("Couldn't create display.");
+ }
}
- }
- Display::~Display()
- {
- dmnsn_delete_display(m_display);
- }
+ Display::~Display()
+ {
+ dmnsn_delete_display(m_display);
+ }
- void
- Display::flush()
- {
- dmnsn_display_frame(m_display);
+ void
+ Display::flush()
+ {
+ dmnsn_display_frame(m_display);
+ }
}
// Print a progress bar of the progress of `progress'
diff --git a/tests/testsxx.hpp b/tests/testsxx.hpp
index 1101196..059b006 100644
--- a/tests/testsxx.hpp
+++ b/tests/testsxx.hpp
@@ -26,21 +26,24 @@
namespace Dimension
{
- // Helper to return a basic scene
- Scene default_scene();
-
- // Display abstraction
- class Display
+ namespace Tests
{
- public:
- Display(const Canvas& canvas);
- ~Display();
-
- void flush();
-
- private:
- dmnsn_display* m_display;
- };
+ // Helper to return a basic scene
+ Scene default_scene();
+
+ // Display abstraction
+ class Display
+ {
+ public:
+ Display(const Canvas& canvas);
+ ~Display();
+
+ void flush();
+
+ private:
+ dmnsn_display* m_display;
+ };
+ }
// Print a progress bar of the progress of `progress'
std::ostream& operator<<(std::ostream& ostr,