=== modified file 'Makefile'
@@ -5,6 +5,7 @@
TESTDIR = test
LIBMATRIX_TESTS = $(TESTDIR)/libmatrix_test
TESTSRCS = $(TESTDIR)/options.cc \
+ $(TESTDIR)/const_vec_test.cc \
$(TESTDIR)/inverse_test.cc \
$(TESTDIR)/transpose_test.cc \
$(TESTDIR)/libmatrix_test.cc
@@ -23,6 +24,7 @@
# Tests and execution targets here.
$(TESTDIR)/options.o: $(TESTDIR)/options.cc $(TESTDIR)/libmatrix_test.h
$(TESTDIR)/libmatrix_test.o: $(TESTDIR)/libmatrix_test.cc $(TESTDIR)/libmatrix_test.h $(TESTDIR)/inverse_test.h $(TESTDIR)/transpose_test.h
+$(TESTDIR)/const_vec_test.o: $(TESTDIR)/const_vec_test.cc $(TESTDIR)/const_vec_test.h $(TESTDIR)/libmatrix_test.h vec.h
$(TESTDIR)/inverse_test.o: $(TESTDIR)/inverse_test.cc $(TESTDIR)/inverse_test.h $(TESTDIR)/libmatrix_test.h mat.h
$(TESTDIR)/transpose_test.o: $(TESTDIR)/transpose_test.cc $(TESTDIR)/transpose_test.h $(TESTDIR)/libmatrix_test.h mat.h
$(TESTDIR)/libmatrix_test: $(TESTOBJS) libmatrix.a
=== added file 'test/const_vec_test.cc'
@@ -0,0 +1,48 @@
+//
+// Copyright (c) 2011 Linaro Limited
+//
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the MIT License which accompanies
+// this distribution, and is available at
+// http://www.opensource.org/licenses/mit-license.php
+//
+// Contributors:
+// Jesse Barker - original implementation.
+//
+#include <iostream>
+#include "libmatrix_test.h"
+#include "const_vec_test.h"
+#include "../vec.h"
+
+using LibMatrix::vec2;
+using LibMatrix::vec3;
+using LibMatrix::vec4;
+using std::cout;
+using std::endl;
+
+void
+Vec2TestConstOperator::run(const Options& options)
+{
+ const vec2 a(1.0, 1.0);
+ const vec2 b(2.0, 2.0);
+ vec2 aplusb(a + b);
+ vec2 aminusb(a - b);
+}
+
+void
+Vec3TestConstOperator::run(const Options& options)
+{
+ const vec3 a(1.0, 1.0, 1.0);
+ const vec3 b(2.0, 2.0, 2.0);
+ vec3 aplusb(a + b);
+ vec3 aminusb(a - b);
+}
+
+void
+Vec4TestConstOperator::run(const Options& options)
+{
+ const vec4 a(1.0, 1.0, 1.0, 1.0);
+ const vec4 b(2.0, 2.0, 2.0, 2.0);
+ vec4 aplusb(a + b);
+ vec4 aminusb(a - b);
+}
=== added file 'test/const_vec_test.h'
@@ -0,0 +1,39 @@
+//
+// Copyright (c) 2011 Linaro Limited
+//
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the MIT License which accompanies
+// this distribution, and is available at
+// http://www.opensource.org/licenses/mit-license.php
+//
+// Contributors:
+// Jesse Barker - original implementation.
+//
+#ifndef CONST_VEC_TEST_H_
+#define CONST_VEC_TEST_H_
+
+class MatrixTest;
+class Options;
+
+class Vec2TestConstOperator : public MatrixTest
+{
+public:
+ Vec2TestConstOperator() : MatrixTest("vec2::const") {}
+ virtual void run(const Options& options);
+};
+
+class Vec3TestConstOperator : public MatrixTest
+{
+public:
+ Vec3TestConstOperator() : MatrixTest("vec3::const") {}
+ virtual void run(const Options& options);
+};
+
+class Vec4TestConstOperator : public MatrixTest
+{
+public:
+ Vec4TestConstOperator() : MatrixTest("vec4::const") {}
+ virtual void run(const Options& options);
+};
+
+#endif // CONST_VEC_TEST_H_
=== modified file 'test/libmatrix_test.cc'
@@ -15,6 +15,7 @@
#include "libmatrix_test.h"
#include "inverse_test.h"
#include "transpose_test.h"
+#include "const_vec_test.h"
using std::cerr;
using std::cout;
=== modified file 'vec.h'
@@ -64,7 +64,7 @@
return *this;
}
- const tvec2 operator/(const T& rhs)
+ const tvec2 operator/(const T& rhs) const
{
return tvec2(*this) /= rhs;
}
@@ -76,7 +76,7 @@
return *this;
}
- const tvec2 operator*(const T& rhs)
+ const tvec2 operator*(const T& rhs) const
{
return tvec2(*this) *= rhs;
}
@@ -88,7 +88,7 @@
return *this;
}
- const tvec2 operator+(const T& rhs)
+ const tvec2 operator+(const T& rhs) const
{
return tvec2(*this) += rhs;
}
@@ -100,7 +100,7 @@
return *this;
}
- const tvec2 operator+(const tvec2& rhs)
+ const tvec2 operator+(const tvec2& rhs) const
{
return tvec2(*this) += rhs;
}
@@ -112,7 +112,7 @@
return *this;
}
- const tvec2 operator-(const T& rhs)
+ const tvec2 operator-(const T& rhs) const
{
return tvec2(*this) -= rhs;
}
@@ -124,7 +124,7 @@
return *this;
}
- const tvec2 operator-(const tvec2& rhs)
+ const tvec2 operator-(const tvec2& rhs) const
{
return tvec2(*this) -= rhs;
}
@@ -206,7 +206,7 @@
return *this;
}
- const tvec3 operator/(const T& rhs)
+ const tvec3 operator/(const T& rhs) const
{
return tvec3(*this) /= rhs;
}
@@ -219,7 +219,7 @@
return *this;
}
- const tvec3 operator*(const T& rhs)
+ const tvec3 operator*(const T& rhs) const
{
return tvec3(*this) *= rhs;
}
@@ -232,7 +232,7 @@
return *this;
}
- const tvec3 operator+(const T& rhs)
+ const tvec3 operator+(const T& rhs) const
{
return tvec3(*this) += rhs;
}
@@ -245,7 +245,7 @@
return *this;
}
- const tvec3 operator+(const tvec3& rhs)
+ const tvec3 operator+(const tvec3& rhs) const
{
return tvec3(*this) += rhs;
}
@@ -258,7 +258,7 @@
return *this;
}
- const tvec3 operator-(const T& rhs)
+ const tvec3 operator-(const T& rhs) const
{
return tvec3(*this) -= rhs;
}
@@ -271,7 +271,7 @@
return *this;
}
- const tvec3 operator-(const tvec3& rhs)
+ const tvec3 operator-(const tvec3& rhs) const
{
return tvec3(*this) -= rhs;
}
@@ -370,7 +370,7 @@
return *this;
}
- const tvec4 operator/(const T& rhs)
+ const tvec4 operator/(const T& rhs) const
{
return tvec4(*this) /= rhs;
}
@@ -384,7 +384,7 @@
return *this;
}
- const tvec4 operator*(const T& rhs)
+ const tvec4 operator*(const T& rhs) const
{
return tvec4(*this) *= rhs;
}
@@ -398,7 +398,7 @@
return *this;
}
- const tvec4 operator+(const T& rhs)
+ const tvec4 operator+(const T& rhs) const
{
return tvec4(*this) += rhs;
}
@@ -412,7 +412,7 @@
return *this;
}
- const tvec4 operator+(const tvec4& rhs)
+ const tvec4 operator+(const tvec4& rhs) const
{
return tvec4(*this) += rhs;
}
@@ -426,7 +426,7 @@
return *this;
}
- const tvec4 operator-(const T& rhs)
+ const tvec4 operator-(const T& rhs) const
{
return tvec4(*this) -= rhs;
}
@@ -440,7 +440,7 @@
return *this;
}
- const tvec4 operator-(const tvec4& rhs)
+ const tvec4 operator-(const tvec4& rhs) const
{
return tvec4(*this) -= rhs;
}