From patchwork Tue Sep 13 16:37:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesse Barker X-Patchwork-Id: 4050 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 47B0D23EFA for ; Tue, 13 Sep 2011 16:37:15 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id 1F91AA18316 for ; Tue, 13 Sep 2011 16:37:15 +0000 (UTC) Received: by fxe23 with SMTP id 23so1000883fxe.11 for ; Tue, 13 Sep 2011 09:37:14 -0700 (PDT) Received: by 10.223.49.209 with SMTP id w17mr1936148faf.8.1315931834871; Tue, 13 Sep 2011 09:37:14 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.11.8 with SMTP id m8cs14855lab; Tue, 13 Sep 2011 09:37:14 -0700 (PDT) Received: by 10.216.177.132 with SMTP id d4mr1225842wem.45.1315931834289; Tue, 13 Sep 2011 09:37:14 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com [91.189.90.7]) by mx.google.com with ESMTPS id o77si2104784weq.143.2011.09.13.09.37.14 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 13 Sep 2011 09:37:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) smtp.mail=bounces@canonical.com Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1R3Vyz-0006Ma-Q4 for ; Tue, 13 Sep 2011 16:37:13 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id B7E9DE02C7 for ; Tue, 13 Sep 2011 16:37:13 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: libmatrix X-Launchpad-Branch: ~jesse-barker/libmatrix/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 24 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~jesse-barker/libmatrix/trunk] Rev 24: Enhance constness of vector addition and subtraction operators. Add a test to Message-Id: <20110913163713.24006.53447.launchpad@ackee.canonical.com> Date: Tue, 13 Sep 2011 16:37:13 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="13921"; Instance="initZopeless config overlay" X-Launchpad-Hash: 37243ea0f45b73456896a253735498a01fb17b3b ------------------------------------------------------------ revno: 24 committer: Jesse Barker branch nick: trunk timestamp: Tue 2011-09-13 09:33:49 -0700 message: Enhance constness of vector addition and subtraction operators. Add a test to enforce this (will fail at compile time). added: test/const_vec_test.cc test/const_vec_test.h modified: Makefile test/libmatrix_test.cc vec.h --- lp:libmatrix https://code.launchpad.net/~jesse-barker/libmatrix/trunk You are subscribed to branch lp:libmatrix. To unsubscribe from this branch go to https://code.launchpad.net/~jesse-barker/libmatrix/trunk/+edit-subscription === modified file 'Makefile' --- Makefile 2011-06-22 23:11:46 +0000 +++ Makefile 2011-09-13 16:33:49 +0000 @@ -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' --- test/const_vec_test.cc 1970-01-01 00:00:00 +0000 +++ test/const_vec_test.cc 2011-09-13 16:33:49 +0000 @@ -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 +#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' --- test/const_vec_test.h 1970-01-01 00:00:00 +0000 +++ test/const_vec_test.h 2011-09-13 16:33:49 +0000 @@ -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' --- test/libmatrix_test.cc 2011-06-22 23:11:46 +0000 +++ test/libmatrix_test.cc 2011-09-13 16:33:49 +0000 @@ -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' --- vec.h 2010-12-17 17:07:27 +0000 +++ vec.h 2011-09-13 16:33:49 +0000 @@ -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; }