From 3745d1254acc386acaadd20016123c9a47b8d10c Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 6 Dec 2012 17:24:41 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system added unit tests for LLUnit --- indra/llcommon/tests/llunit_test.cpp | 156 +++++++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 indra/llcommon/tests/llunit_test.cpp (limited to 'indra/llcommon/tests') diff --git a/indra/llcommon/tests/llunit_test.cpp b/indra/llcommon/tests/llunit_test.cpp new file mode 100644 index 0000000000..a7e9c00740 --- /dev/null +++ b/indra/llcommon/tests/llunit_test.cpp @@ -0,0 +1,156 @@ +/** + * @file llsingleton_test.cpp + * @date 2011-08-11 + * @brief Unit test for the LLSingleton class + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "linden_common.h" + +#include "llunit.h" +#include "../test/lltut.h" + +namespace LLUnits +{ + // using powers of 2 to allow strict floating point equality + struct Quatloos { typedef Quatloos base_unit_t; }; + LL_DECLARE_DERIVED_UNIT(4, Quatloos, Latinum); + LL_DECLARE_DERIVED_UNIT((1.0 / 4.0), Quatloos, Solari); +} + +namespace tut +{ + using namespace LLUnits; + struct units + { + }; + + typedef test_group units_t; + typedef units_t::object units_object_t; + tut::units_t tut_singleton("LLUnit"); + + // storage type conversions + template<> template<> + void units_object_t::test<1>() + { + LLUnit float_quatloos; + ensure(float_quatloos.value() == 0.f); + + LLUnit int_quatloos; + ensure(int_quatloos.value() == 0); + + int_quatloos = 42; + ensure(int_quatloos.value() == 42); + float_quatloos = int_quatloos; + ensure(float_quatloos.value() == 42.f); + + int_quatloos = float_quatloos; + ensure(int_quatloos.value() == 42); + + float_quatloos = 42.1f; + ensure(float_quatloos == 42.1f); + int_quatloos = float_quatloos; + ensure(int_quatloos.value() == 42); + LLUnit unsigned_int_quatloos(float_quatloos); + ensure(unsigned_int_quatloos.value() == 42); + } + + // conversions to/from base unit + template<> template<> + void units_object_t::test<2>() + { + LLUnit quatloos(1.f); + ensure(quatloos.value() == 1.f); + LLUnit latinum_bars(quatloos); + ensure(latinum_bars.value() == 1.f / 4.f); + + latinum_bars = 256; + quatloos = latinum_bars; + ensure(quatloos.value() == 1024); + + LLUnit solari(quatloos); + ensure(solari.value() == 4096); + } + + // conversions across non-base units + template<> template<> + void units_object_t::test<3>() + { + LLUnit solari = 4.f; + LLUnit latinum_bars = solari; + ensure(latinum_bars.value() == 0.25f); + } + + // math operations + template<> template<> + void units_object_t::test<4>() + { + LLUnit quatloos = 1.f; + quatloos *= 4.f; + ensure(quatloos.value() == 4); + quatloos = quatloos * 2; + ensure(quatloos.value() == 8); + quatloos = 2.f * quatloos; + ensure(quatloos.value() == 16); + + quatloos += 4.f; + ensure(quatloos.value() == 20); + quatloos += 4; + ensure(quatloos.value() == 24); + quatloos = quatloos + 4; + ensure(quatloos.value() == 28); + quatloos = 4 + quatloos; + ensure(quatloos.value() == 32); + quatloos += quatloos * 3; + ensure(quatloos.value() == 128); + + quatloos -= quatloos / 4 * 3; + ensure(quatloos.value() == 32); + quatloos = quatloos - 8; + ensure(quatloos.value() == 24); + quatloos -= 4; + ensure(quatloos.value() == 20); + quatloos -= 4.f; + ensure(quatloos.value() == 16); + + quatloos *= 2.f; + ensure(quatloos.value() == 32); + quatloos = quatloos * 2.f; + ensure(quatloos.value() == 64); + quatloos = 0.5f * quatloos; + ensure(quatloos.value() == 32); + + quatloos /= 2.f; + ensure(quatloos.value() == 16); + quatloos = quatloos / 4; + ensure(quatloos.value() == 4); + + F32 ratio = quatloos / LLUnit(4.f); + ensure(ratio == 1); + + quatloos += LLUnit(4.f); + ensure(quatloos.value() == 5); + quatloos -= LLUnit(1.f); + ensure(quatloos.value() == 1); + } +} -- cgit v1.2.3 From c99886d94389babc78e92bbfa5084fdd785915af Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 7 Dec 2012 15:20:12 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system improved unit tests for LLUnit renamed LLUnit to LLUnitImplicit with LLUnit being reserved for explicit units --- indra/llcommon/tests/llunit_test.cpp | 156 ------------------------- indra/llcommon/tests/llunits_test.cpp | 208 ++++++++++++++++++++++++++++++++++ 2 files changed, 208 insertions(+), 156 deletions(-) delete mode 100644 indra/llcommon/tests/llunit_test.cpp create mode 100644 indra/llcommon/tests/llunits_test.cpp (limited to 'indra/llcommon/tests') diff --git a/indra/llcommon/tests/llunit_test.cpp b/indra/llcommon/tests/llunit_test.cpp deleted file mode 100644 index a7e9c00740..0000000000 --- a/indra/llcommon/tests/llunit_test.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/** - * @file llsingleton_test.cpp - * @date 2011-08-11 - * @brief Unit test for the LLSingleton class - * - * $LicenseInfo:firstyear=2011&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "linden_common.h" - -#include "llunit.h" -#include "../test/lltut.h" - -namespace LLUnits -{ - // using powers of 2 to allow strict floating point equality - struct Quatloos { typedef Quatloos base_unit_t; }; - LL_DECLARE_DERIVED_UNIT(4, Quatloos, Latinum); - LL_DECLARE_DERIVED_UNIT((1.0 / 4.0), Quatloos, Solari); -} - -namespace tut -{ - using namespace LLUnits; - struct units - { - }; - - typedef test_group units_t; - typedef units_t::object units_object_t; - tut::units_t tut_singleton("LLUnit"); - - // storage type conversions - template<> template<> - void units_object_t::test<1>() - { - LLUnit float_quatloos; - ensure(float_quatloos.value() == 0.f); - - LLUnit int_quatloos; - ensure(int_quatloos.value() == 0); - - int_quatloos = 42; - ensure(int_quatloos.value() == 42); - float_quatloos = int_quatloos; - ensure(float_quatloos.value() == 42.f); - - int_quatloos = float_quatloos; - ensure(int_quatloos.value() == 42); - - float_quatloos = 42.1f; - ensure(float_quatloos == 42.1f); - int_quatloos = float_quatloos; - ensure(int_quatloos.value() == 42); - LLUnit unsigned_int_quatloos(float_quatloos); - ensure(unsigned_int_quatloos.value() == 42); - } - - // conversions to/from base unit - template<> template<> - void units_object_t::test<2>() - { - LLUnit quatloos(1.f); - ensure(quatloos.value() == 1.f); - LLUnit latinum_bars(quatloos); - ensure(latinum_bars.value() == 1.f / 4.f); - - latinum_bars = 256; - quatloos = latinum_bars; - ensure(quatloos.value() == 1024); - - LLUnit solari(quatloos); - ensure(solari.value() == 4096); - } - - // conversions across non-base units - template<> template<> - void units_object_t::test<3>() - { - LLUnit solari = 4.f; - LLUnit latinum_bars = solari; - ensure(latinum_bars.value() == 0.25f); - } - - // math operations - template<> template<> - void units_object_t::test<4>() - { - LLUnit quatloos = 1.f; - quatloos *= 4.f; - ensure(quatloos.value() == 4); - quatloos = quatloos * 2; - ensure(quatloos.value() == 8); - quatloos = 2.f * quatloos; - ensure(quatloos.value() == 16); - - quatloos += 4.f; - ensure(quatloos.value() == 20); - quatloos += 4; - ensure(quatloos.value() == 24); - quatloos = quatloos + 4; - ensure(quatloos.value() == 28); - quatloos = 4 + quatloos; - ensure(quatloos.value() == 32); - quatloos += quatloos * 3; - ensure(quatloos.value() == 128); - - quatloos -= quatloos / 4 * 3; - ensure(quatloos.value() == 32); - quatloos = quatloos - 8; - ensure(quatloos.value() == 24); - quatloos -= 4; - ensure(quatloos.value() == 20); - quatloos -= 4.f; - ensure(quatloos.value() == 16); - - quatloos *= 2.f; - ensure(quatloos.value() == 32); - quatloos = quatloos * 2.f; - ensure(quatloos.value() == 64); - quatloos = 0.5f * quatloos; - ensure(quatloos.value() == 32); - - quatloos /= 2.f; - ensure(quatloos.value() == 16); - quatloos = quatloos / 4; - ensure(quatloos.value() == 4); - - F32 ratio = quatloos / LLUnit(4.f); - ensure(ratio == 1); - - quatloos += LLUnit(4.f); - ensure(quatloos.value() == 5); - quatloos -= LLUnit(1.f); - ensure(quatloos.value() == 1); - } -} diff --git a/indra/llcommon/tests/llunits_test.cpp b/indra/llcommon/tests/llunits_test.cpp new file mode 100644 index 0000000000..2a941e8229 --- /dev/null +++ b/indra/llcommon/tests/llunits_test.cpp @@ -0,0 +1,208 @@ +/** + * @file llsingleton_test.cpp + * @date 2011-08-11 + * @brief Unit test for the LLSingleton class + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "linden_common.h" + +#include "llunit.h" +#include "../test/lltut.h" + +namespace LLUnits +{ + // using powers of 2 to allow strict floating point equality + struct Quatloos { typedef Quatloos base_unit_t; }; + LL_DECLARE_DERIVED_UNIT(4, Quatloos, Latinum); + LL_DECLARE_DERIVED_UNIT((1.0 / 4.0), Quatloos, Solari); +} + +namespace tut +{ + using namespace LLUnits; + struct units + { + }; + + typedef test_group units_t; + typedef units_t::object units_object_t; + tut::units_t tut_singleton("LLUnit"); + + // storage type conversions + template<> template<> + void units_object_t::test<1>() + { + LLUnit float_quatloos; + ensure(float_quatloos.value() == 0.f); + + LLUnit int_quatloos; + ensure(int_quatloos.value() == 0); + + int_quatloos = 42; + ensure(int_quatloos.value() == 42); + float_quatloos = int_quatloos; + ensure(float_quatloos.value() == 42.f); + + int_quatloos = float_quatloos; + ensure(int_quatloos.value() == 42); + + float_quatloos = 42.1f; + ensure(float_quatloos.value() == 42.1f); + int_quatloos = float_quatloos; + ensure(int_quatloos.value() == 42); + LLUnit unsigned_int_quatloos(float_quatloos); + ensure(unsigned_int_quatloos.value() == 42); + } + + // conversions to/from base unit + template<> template<> + void units_object_t::test<2>() + { + LLUnit quatloos(1.f); + ensure(quatloos.value() == 1.f); + LLUnit latinum_bars(quatloos); + ensure(latinum_bars.value() == 1.f / 4.f); + + latinum_bars = 256; + quatloos = latinum_bars; + ensure(quatloos.value() == 1024); + + LLUnit solari(quatloos); + ensure(solari.value() == 4096); + } + + // conversions across non-base units + template<> template<> + void units_object_t::test<3>() + { + LLUnit solari = 4.f; + LLUnit latinum_bars = solari; + ensure(latinum_bars.value() == 0.25f); + } + + // math operations + template<> template<> + void units_object_t::test<4>() + { + LLUnit quatloos = 1.f; + quatloos *= 4.f; + ensure(quatloos.value() == 4); + quatloos = quatloos * 2; + ensure(quatloos.value() == 8); + quatloos = 2.f * quatloos; + ensure(quatloos.value() == 16); + + quatloos += 4.f; + ensure(quatloos.value() == 20); + quatloos += 4; + ensure(quatloos.value() == 24); + quatloos = quatloos + 4; + ensure(quatloos.value() == 28); + quatloos = 4 + quatloos; + ensure(quatloos.value() == 32); + quatloos += quatloos * 3; + ensure(quatloos.value() == 128); + + quatloos -= quatloos / 4 * 3; + ensure(quatloos.value() == 32); + quatloos = quatloos - 8; + ensure(quatloos.value() == 24); + quatloos -= 4; + ensure(quatloos.value() == 20); + quatloos -= 4.f; + ensure(quatloos.value() == 16); + + quatloos *= 2.f; + ensure(quatloos.value() == 32); + quatloos = quatloos * 2.f; + ensure(quatloos.value() == 64); + quatloos = 0.5f * quatloos; + ensure(quatloos.value() == 32); + + quatloos /= 2.f; + ensure(quatloos.value() == 16); + quatloos = quatloos / 4; + ensure(quatloos.value() == 4); + + F32 ratio = quatloos / LLUnit(4.f); + ensure(ratio == 1); + + quatloos += LLUnit(4.f); + ensure(quatloos.value() == 5); + quatloos -= LLUnit(1.f); + ensure(quatloos.value() == 1); + } + + // implicit units + template<> template<> + void units_object_t::test<5>() + { + // 0-initialized + LLUnit quatloos(0); + // initialize implicit unit from explicit + LLUnitImplicit quatloos_implicit = quatloos + 1; + ensure(quatloos_implicit.value() == 1); + + // assign implicit to explicit, or perform math operations + quatloos = quatloos_implicit; + ensure(quatloos.value() == 1); + quatloos += quatloos_implicit; + ensure(quatloos.value() == 2); + + // math operations on implicits + quatloos_implicit = 1; + ensure(quatloos_implicit == 1); + + quatloos_implicit += 2; + ensure(quatloos_implicit == 3); + + quatloos_implicit *= 2; + ensure(quatloos_implicit == 6); + + quatloos_implicit -= 1; + ensure(quatloos_implicit == 5); + + quatloos_implicit /= 5; + ensure(quatloos_implicit == 1); + + quatloos_implicit = quatloos_implicit + 3 + quatloos_implicit; + ensure(quatloos_implicit == 5); + + quatloos_implicit = 10 - quatloos_implicit - 1; + ensure(quatloos_implicit == 4); + + quatloos_implicit = 2 * quatloos_implicit * 2; + ensure(quatloos_implicit == 16); + + F32 one_half = quatloos_implicit / (quatloos_implicit * 2); + ensure(one_half == 0.5f); + + // implicit conversion to POD + F32 float_val = quatloos_implicit; + ensure(float_val == 16); + + S32 int_val = quatloos_implicit; + ensure(int_val == 16); + } +} -- cgit v1.2.3 From 6b81b8629e67d82a7620e48781ded73b6e6126ea Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sun, 5 May 2013 17:45:35 -0700 Subject: Spring cleaning: removed unused .cpp and.h files, and cleaned up header dependencies --- indra/llcommon/tests/reflection_test.cpp | 220 ------------------------------- 1 file changed, 220 deletions(-) delete mode 100644 indra/llcommon/tests/reflection_test.cpp (limited to 'indra/llcommon/tests') diff --git a/indra/llcommon/tests/reflection_test.cpp b/indra/llcommon/tests/reflection_test.cpp deleted file mode 100644 index 8980ebb1f1..0000000000 --- a/indra/llcommon/tests/reflection_test.cpp +++ /dev/null @@ -1,220 +0,0 @@ -/** - * @file reflection_test.cpp - * @date May 2006 - * @brief Reflection unit tests. - * - * $LicenseInfo:firstyear=2006&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "../linden_common.h" -#include "../reflective.h" -#include "../metaclasst.h" -#include "../metapropertyt.h" -#include "../stdtypes.h" - -#include "../test/lltut.h" - -namespace tut -{ - class TestAggregatedData : public LLReflective - { - public: - TestAggregatedData() {;} - virtual const LLMetaClass& getMetaClass() const; - - private: - }; - - class TestReflectionData : public LLReflective - { - public: - TestReflectionData() : mInt(42), mString("foo"), mNullPtr(NULL), mPtr(new TestAggregatedData()), mRef(*(new TestAggregatedData)) {;} - virtual ~TestReflectionData() {delete mPtr;} - virtual const LLMetaClass& getMetaClass() const; - - static U32 getPropertyCount() {return 5;} - - private: - - friend class LLMetaClassT; - S32 mInt; - std::string mString; - TestAggregatedData* mNullPtr; - TestAggregatedData* mPtr; - TestAggregatedData mObj; - TestAggregatedData& mRef; - }; -} - -template <> -void LLMetaClassT::reflectProperties(LLMetaClass& meta_class) -{ - reflectProperty(meta_class, "mInt", &tut::TestReflectionData::mInt); - reflectProperty(meta_class, "mString", &tut::TestReflectionData::mString); - reflectPtrProperty(meta_class, "mNullPtr", &tut::TestReflectionData::mNullPtr); - reflectPtrProperty(meta_class, "mPtr", &tut::TestReflectionData::mPtr); - reflectProperty(meta_class, "mObj", &tut::TestReflectionData::mObj); - //reflectProperty(meta_class, "mRef", &tut::TestReflectionData::mRef); // AARGH! -} - -namespace tut -{ - // virtual - const LLMetaClass& TestReflectionData::getMetaClass() const - { - return LLMetaClassT::instance(); - } - - const LLMetaClass& TestAggregatedData::getMetaClass() const - { - return LLMetaClassT::instance(); - } -} - -namespace tut -{ - typedef tut::test_group TestReflectionGroup; - typedef TestReflectionGroup::object TestReflectionObject; - TestReflectionGroup gTestReflectionGroup("reflection"); - - template<> template<> - void TestReflectionObject::test<1>() - { - // Check properties can be found. - const LLMetaClass& meta_class = LLMetaClassT::instance(); - const LLMetaProperty* null = NULL; - ensure_not_equals(meta_class.findProperty("mInt"), null); - ensure_not_equals(meta_class.findProperty("mString"), null); - } - - template<> template<> - void TestReflectionObject::test<2>() - { - // Check non-existent property cannot be found. - const LLMetaClass& meta_class = LLMetaClassT::instance(); - const LLMetaProperty* null = NULL; - ensure_equals(meta_class.findProperty("foo"), null); - } - - template<> template<> - void TestReflectionObject::test<3>() - { - // Check integer property has correct value. - const LLMetaClass& meta_class = LLMetaClassT::instance(); - ensure_equals(meta_class.findProperty("mInt")->getLLSD(this).asInteger(), 42); - } - - template<> template<> - void TestReflectionObject::test<4>() - { - // Check string property has correct value. - const LLMetaClass& meta_class = LLMetaClassT::instance(); - ensure_equals(meta_class.findProperty("mString")->getLLSD(this).asString(), std::string("foo")); - } - - template<> template<> - void TestReflectionObject::test<5>() - { - // Check NULL reference property has correct value. - const LLMetaClass& meta_class = LLMetaClassT::instance(); - const LLReflective* null = NULL; - ensure_equals(meta_class.findProperty("mNullPtr")->get(this), null); - } - - template<> template<> - void TestReflectionObject::test<6>() - { - // Check reference property has correct value. - const LLMetaClass& meta_class = LLMetaClassT::instance(); - const LLReflective* null = NULL; - const LLReflective* ref = meta_class.findProperty("mPtr")->get(this); - ensure_not_equals(ref, null); - } - - template<> template<> - void TestReflectionObject::test<7>() - { - // Check reflective property has correct value. - const LLMetaClass& meta_class = LLMetaClassT::instance(); - const LLReflective* null = NULL; - const LLReflective* ref = meta_class.findProperty("mObj")->get(this); - ensure_not_equals(ref, null); - } - - template<> template<> - void TestReflectionObject::test<8>() - { - // Check property count. - const LLMetaClass& meta_class = LLMetaClassT::instance(); - ensure_equals(meta_class.getPropertyCount(), TestReflectionData::getPropertyCount()); - } - - template<> template<> - void TestReflectionObject::test<9>() - { - // Check property iteration. - const LLMetaClass& meta_class = LLMetaClassT::instance(); - U32 count = 0; - LLMetaClass::PropertyIterator iter; - for(iter = meta_class.beginProperties(); iter != meta_class.endProperties(); ++iter) - { - ++count; - } - ensure_equals(count, TestReflectionData::getPropertyCount()); - } - - template<> template<> - void TestReflectionObject::test<10>() - { - // Check meta classes of different types do not compare equal. - const LLMetaClass* reflection_data_meta_class = &(LLMetaClassT::instance()); - const LLMetaClass* aggregated_data_meta_class = &(LLMetaClassT::instance()); - ensure_not_equals(reflection_data_meta_class, aggregated_data_meta_class); - } - - template<> template<> - void TestReflectionObject::test<11>() - { - // Check class cast checks. - const LLMetaClass& meta_class = LLMetaClassT::instance(); - TestAggregatedData* aggregated_data = new TestAggregatedData(); - LLMetaClass::PropertyIterator iter; - U32 exception_count = 0; - for(iter = meta_class.beginProperties(); iter != meta_class.endProperties(); ++iter) - { - try - { - const LLMetaProperty* property = (*iter).second; - const LLReflective* reflective = property->get(aggregated_data); // Wrong reflective type, should throw exception. - - // useless op to get rid of compiler warning. - reflective = reflective; - } - catch(...) - { - ++exception_count; - } - } - ensure_equals(exception_count, getPropertyCount()); - - } -} -- cgit v1.2.3 From 60b625588faec2472597dae50331b2ce95ce40a2 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 5 Jun 2013 19:57:07 -0700 Subject: BUILDFIX: build fixes for mac --- indra/llcommon/tests/llunits_test.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/llcommon/tests') diff --git a/indra/llcommon/tests/llunits_test.cpp b/indra/llcommon/tests/llunits_test.cpp index 2a941e8229..33e30f9688 100644 --- a/indra/llcommon/tests/llunits_test.cpp +++ b/indra/llcommon/tests/llunits_test.cpp @@ -33,9 +33,9 @@ namespace LLUnits { // using powers of 2 to allow strict floating point equality - struct Quatloos { typedef Quatloos base_unit_t; }; - LL_DECLARE_DERIVED_UNIT(4, Quatloos, Latinum); - LL_DECLARE_DERIVED_UNIT((1.0 / 4.0), Quatloos, Solari); + LL_DECLARE_BASE_UNIT(Quatloos, "Quat"); + LL_DECLARE_DERIVED_UNIT(4, Quatloos, Latinum, "Lat"); + LL_DECLARE_DERIVED_UNIT((1.0 / 4.0), Quatloos, Solari, "Sol"); } namespace tut -- cgit v1.2.3 From 9fd3af3c389ed491b515cbb5136b344b069913e4 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 13 Jun 2013 15:29:15 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics changed Units macros and argument order to make it more clear optimized units for integer types fixed merging of periodicrecordings...should eliminate duplicate entries in sceneloadmonitor history --- indra/llcommon/tests/llunits_test.cpp | 104 +++++++++++++++++----------------- 1 file changed, 53 insertions(+), 51 deletions(-) (limited to 'indra/llcommon/tests') diff --git a/indra/llcommon/tests/llunits_test.cpp b/indra/llcommon/tests/llunits_test.cpp index 33e30f9688..747e8d1827 100644 --- a/indra/llcommon/tests/llunits_test.cpp +++ b/indra/llcommon/tests/llunits_test.cpp @@ -34,8 +34,8 @@ namespace LLUnits { // using powers of 2 to allow strict floating point equality LL_DECLARE_BASE_UNIT(Quatloos, "Quat"); - LL_DECLARE_DERIVED_UNIT(4, Quatloos, Latinum, "Lat"); - LL_DECLARE_DERIVED_UNIT((1.0 / 4.0), Quatloos, Solari, "Sol"); + LL_DECLARE_DERIVED_UNIT(Latinum, "Lat", Quatloos, * 4); + LL_DECLARE_DERIVED_UNIT(Solari, "Sol", Quatloos, / 4); } namespace tut @@ -53,105 +53,107 @@ namespace tut template<> template<> void units_object_t::test<1>() { - LLUnit float_quatloos; - ensure(float_quatloos.value() == 0.f); + LLUnit float_quatloos; + ensure(float_quatloos == 0.f); - LLUnit int_quatloos; - ensure(int_quatloos.value() == 0); + LLUnit int_quatloos; + ensure(int_quatloos == 0); int_quatloos = 42; - ensure(int_quatloos.value() == 42); + ensure(int_quatloos == 42); float_quatloos = int_quatloos; - ensure(float_quatloos.value() == 42.f); + ensure(float_quatloos == 42.f); int_quatloos = float_quatloos; - ensure(int_quatloos.value() == 42); + ensure(int_quatloos == 42); float_quatloos = 42.1f; - ensure(float_quatloos.value() == 42.1f); + ensure(float_quatloos == 42.1f); int_quatloos = float_quatloos; - ensure(int_quatloos.value() == 42); - LLUnit unsigned_int_quatloos(float_quatloos); - ensure(unsigned_int_quatloos.value() == 42); + ensure(int_quatloos == 42); + LLUnit unsigned_int_quatloos(float_quatloos); + ensure(unsigned_int_quatloos == 42); } // conversions to/from base unit template<> template<> void units_object_t::test<2>() { - LLUnit quatloos(1.f); - ensure(quatloos.value() == 1.f); - LLUnit latinum_bars(quatloos); - ensure(latinum_bars.value() == 1.f / 4.f); + LLUnit quatloos(1.f); + ensure(quatloos == 1.f); + LLUnit latinum_bars(quatloos); + ensure(latinum_bars == 1.f / 4.f); latinum_bars = 256; quatloos = latinum_bars; - ensure(quatloos.value() == 1024); + ensure(quatloos == 1024); - LLUnit solari(quatloos); - ensure(solari.value() == 4096); + LLUnit solari(quatloos); + ensure(solari == 4096); } // conversions across non-base units template<> template<> void units_object_t::test<3>() { - LLUnit solari = 4.f; - LLUnit latinum_bars = solari; - ensure(latinum_bars.value() == 0.25f); + LLUnit solari = 4.f; + LLUnit latinum_bars = solari; + ensure(latinum_bars == 0.25f); } // math operations template<> template<> void units_object_t::test<4>() { - LLUnit quatloos = 1.f; + LLUnit quatloos = 1.f; quatloos *= 4.f; - ensure(quatloos.value() == 4); + ensure(quatloos == 4); quatloos = quatloos * 2; - ensure(quatloos.value() == 8); + ensure(quatloos == 8); quatloos = 2.f * quatloos; - ensure(quatloos.value() == 16); + ensure(quatloos == 16); quatloos += 4.f; - ensure(quatloos.value() == 20); + ensure(quatloos == 20); quatloos += 4; - ensure(quatloos.value() == 24); + ensure(quatloos == 24); quatloos = quatloos + 4; - ensure(quatloos.value() == 28); + ensure(quatloos == 28); quatloos = 4 + quatloos; - ensure(quatloos.value() == 32); + ensure(quatloos == 32); quatloos += quatloos * 3; - ensure(quatloos.value() == 128); + ensure(quatloos == 128); quatloos -= quatloos / 4 * 3; - ensure(quatloos.value() == 32); + ensure(quatloos == 32); quatloos = quatloos - 8; - ensure(quatloos.value() == 24); + ensure(quatloos == 24); quatloos -= 4; - ensure(quatloos.value() == 20); + ensure(quatloos == 20); quatloos -= 4.f; - ensure(quatloos.value() == 16); + ensure(quatloos == 16); quatloos *= 2.f; - ensure(quatloos.value() == 32); + ensure(quatloos == 32); quatloos = quatloos * 2.f; - ensure(quatloos.value() == 64); + ensure(quatloos == 64); quatloos = 0.5f * quatloos; - ensure(quatloos.value() == 32); + ensure(quatloos == 32); quatloos /= 2.f; - ensure(quatloos.value() == 16); + ensure(quatloos == 16); quatloos = quatloos / 4; - ensure(quatloos.value() == 4); + ensure(quatloos == 4); - F32 ratio = quatloos / LLUnit(4.f); + F32 ratio = quatloos / LLUnit(4.f); + ensure(ratio == 1); + ratio = quatloos / LLUnit(16.f); ensure(ratio == 1); - quatloos += LLUnit(4.f); - ensure(quatloos.value() == 5); - quatloos -= LLUnit(1.f); - ensure(quatloos.value() == 1); + quatloos += LLUnit(4.f); + ensure(quatloos == 5); + quatloos -= LLUnit(1.f); + ensure(quatloos == 1); } // implicit units @@ -159,16 +161,16 @@ namespace tut void units_object_t::test<5>() { // 0-initialized - LLUnit quatloos(0); + LLUnit quatloos(0); // initialize implicit unit from explicit - LLUnitImplicit quatloos_implicit = quatloos + 1; - ensure(quatloos_implicit.value() == 1); + LLUnitImplicit quatloos_implicit = quatloos + 1; + ensure(quatloos_implicit == 1); // assign implicit to explicit, or perform math operations quatloos = quatloos_implicit; - ensure(quatloos.value() == 1); + ensure(quatloos == 1); quatloos += quatloos_implicit; - ensure(quatloos.value() == 2); + ensure(quatloos == 2); // math operations on implicits quatloos_implicit = 1; -- cgit v1.2.3 From 3f2de87340b1c831ea59e4a3ca960d49f343c9fd Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 17 Jun 2013 01:18:21 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics added getAs and setAs to LLUnit to make it clearer how you specify units removed accidental 0-based indexing of periodicRecording history... should now be consistently 1-based, with 0 accessing current active recording removed per frame timer updates of all historical timer bars in fast timer display added missing assignment operator to recordings --- indra/llcommon/tests/llunits_test.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'indra/llcommon/tests') diff --git a/indra/llcommon/tests/llunits_test.cpp b/indra/llcommon/tests/llunits_test.cpp index 747e8d1827..04764f6c2f 100644 --- a/indra/llcommon/tests/llunits_test.cpp +++ b/indra/llcommon/tests/llunits_test.cpp @@ -35,7 +35,7 @@ namespace LLUnits // using powers of 2 to allow strict floating point equality LL_DECLARE_BASE_UNIT(Quatloos, "Quat"); LL_DECLARE_DERIVED_UNIT(Latinum, "Lat", Quatloos, * 4); - LL_DECLARE_DERIVED_UNIT(Solari, "Sol", Quatloos, / 4); + LL_DECLARE_DERIVED_UNIT(Solari, "Sol", Latinum, / 16); } namespace tut @@ -206,5 +206,11 @@ namespace tut S32 int_val = quatloos_implicit; ensure(int_val == 16); + + // conversion of implicits + LLUnitImplicit latinum_implicit(2); + ensure(latinum_implicit == 2); + + ensure(latinum_implicit * 2 == quatloos_implicit); } } -- cgit v1.2.3 From d136c4c29686c565b5a46503aa67a9c958b4145d Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 18 Jun 2013 23:41:53 -0700 Subject: SH-4246 FIX interesting: fast timers significantly decreases framerate removed implicit flushes on reads from recorders for better performance made sure stack timers were updated on recorder deactivate faster rendering and better ui for fast timer view --- indra/llcommon/tests/llunits_test.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'indra/llcommon/tests') diff --git a/indra/llcommon/tests/llunits_test.cpp b/indra/llcommon/tests/llunits_test.cpp index 04764f6c2f..a5df51f6de 100644 --- a/indra/llcommon/tests/llunits_test.cpp +++ b/indra/llcommon/tests/llunits_test.cpp @@ -56,6 +56,9 @@ namespace tut LLUnit float_quatloos; ensure(float_quatloos == 0.f); + LLUnit float_initialize_quatloos(1); + ensure(float_initialize_quatloos == 1.f); + LLUnit int_quatloos; ensure(int_quatloos == 0); -- cgit v1.2.3 From 4ff19b8f63f3814e98049064254323716f0fd422 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sat, 20 Jul 2013 09:41:55 -0700 Subject: removed debug spam fast timer data now resets on login --- indra/llcommon/tests/llunits_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/tests') diff --git a/indra/llcommon/tests/llunits_test.cpp b/indra/llcommon/tests/llunits_test.cpp index a5df51f6de..2074a4f4d9 100644 --- a/indra/llcommon/tests/llunits_test.cpp +++ b/indra/llcommon/tests/llunits_test.cpp @@ -164,7 +164,7 @@ namespace tut void units_object_t::test<5>() { // 0-initialized - LLUnit quatloos(0); + LLUnit quatloos; // initialize implicit unit from explicit LLUnitImplicit quatloos_implicit = quatloos + 1; ensure(quatloos_implicit == 1); -- cgit v1.2.3 From 7e7b9ddc32c1eac5f7269cce69f9321d3d17f577 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 24 Jul 2013 11:24:41 -0700 Subject: BUILDFIX fixed llunits unit test to use new unit declaration syntax --- indra/llcommon/tests/llunits_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llcommon/tests') diff --git a/indra/llcommon/tests/llunits_test.cpp b/indra/llcommon/tests/llunits_test.cpp index 2074a4f4d9..e631f18ad4 100644 --- a/indra/llcommon/tests/llunits_test.cpp +++ b/indra/llcommon/tests/llunits_test.cpp @@ -34,8 +34,8 @@ namespace LLUnits { // using powers of 2 to allow strict floating point equality LL_DECLARE_BASE_UNIT(Quatloos, "Quat"); - LL_DECLARE_DERIVED_UNIT(Latinum, "Lat", Quatloos, * 4); - LL_DECLARE_DERIVED_UNIT(Solari, "Sol", Latinum, / 16); + LL_DECLARE_DERIVED_UNIT(Quatloos, * 4, Latinum, "Lat"); + LL_DECLARE_DERIVED_UNIT(Latinum, / 16, Solari, "Sol"); } namespace tut -- cgit v1.2.3 From a2e22732f195dc075a733c79f15156752f522a43 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 30 Jul 2013 19:13:45 -0700 Subject: Summer cleaning - removed a lot of llcommon dependencies to speed up build times consolidated most indra-specific constants in llcommon under indra_constants.h fixed issues with operations on mixed unit types (implicit and explicit) made LL_INFOS() style macros variadic in order to subsume other logging methods such as ll_infos added optional tag output to error recorders --- indra/llcommon/tests/bitpack_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/tests') diff --git a/indra/llcommon/tests/bitpack_test.cpp b/indra/llcommon/tests/bitpack_test.cpp index afc0c18cd0..9bfd567068 100755 --- a/indra/llcommon/tests/bitpack_test.cpp +++ b/indra/llcommon/tests/bitpack_test.cpp @@ -28,7 +28,7 @@ #include "linden_common.h" -#include "../bitpack.h" +#include "../llbitpack.h" #include "../test/lltut.h" -- cgit v1.2.3 From cc31b4ae7934010762b8aaaa7e190c74a1cd7820 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 12 Aug 2013 20:05:16 -0700 Subject: SH-4399 FIX: Interesting: Texture console MB Bound 0/384 and texture queue bounces once per second SH-4346 FIX: Interesting: some integer Statistics are displayed as floating point after crossing region boundary made llerrs/infos/etc properly variadic wrt tags LL_INFOS("A", "B", "C") works, for example fixed unit tests remove llsimplestat --- indra/llcommon/tests/commonmisc_test.cpp | 10 ++-- indra/llcommon/tests/llerror_test.cpp | 90 ++++++++++++++--------------- indra/llcommon/tests/llsdserialize_test.cpp | 2 +- indra/llcommon/tests/llunits_test.cpp | 6 ++ 4 files changed, 57 insertions(+), 51 deletions(-) (limited to 'indra/llcommon/tests') diff --git a/indra/llcommon/tests/commonmisc_test.cpp b/indra/llcommon/tests/commonmisc_test.cpp index b115c153c1..4b3e07fa75 100755 --- a/indra/llcommon/tests/commonmisc_test.cpp +++ b/indra/llcommon/tests/commonmisc_test.cpp @@ -339,7 +339,7 @@ namespace tut /* if(actual != expected) { - llwarns << "iteration " << i << llendl; + LL_WARNS() << "iteration " << i << LL_ENDL; std::ostringstream e_str; std::string::iterator iter = expected.begin(); std::string::iterator end = expected.end(); @@ -349,8 +349,8 @@ namespace tut } e_str << std::endl; llsd_serialize_string(e_str, expected); - llwarns << "expected size: " << expected.size() << llendl; - llwarns << "expected: " << e_str.str() << llendl; + LL_WARNS() << "expected size: " << expected.size() << LL_ENDL; + LL_WARNS() << "expected: " << e_str.str() << LL_ENDL; std::ostringstream a_str; iter = actual.begin(); @@ -361,8 +361,8 @@ namespace tut } a_str << std::endl; llsd_serialize_string(a_str, actual); - llwarns << "actual size: " << actual.size() << llendl; - llwarns << "actual: " << a_str.str() << llendl; + LL_WARNS() << "actual size: " << actual.size() << LL_ENDL; + LL_WARNS() << "actual: " << a_str.str() << LL_ENDL; } */ ensure_equals("string value", actual, expected); diff --git a/indra/llcommon/tests/llerror_test.cpp b/indra/llcommon/tests/llerror_test.cpp index 279a90e51b..b28c5ba4b3 100755 --- a/indra/llcommon/tests/llerror_test.cpp +++ b/indra/llcommon/tests/llerror_test.cpp @@ -40,7 +40,7 @@ namespace { void test_that_error_h_includes_enough_things_to_compile_a_message() { - llinfos << "!" << llendl; + LL_INFOS() << "!" << LL_ENDL; } } @@ -55,7 +55,7 @@ namespace tut class TestRecorder : public LLError::Recorder { public: - TestRecorder() : mWantsTime(false) { } + TestRecorder() { mWantsTime = false; } ~TestRecorder() { LLError::removeRecorder(this); } void recordMessage(LLError::ELevel level, @@ -68,7 +68,6 @@ namespace tut void clearMessages() { mMessages.clear(); } void setWantsTime(bool t) { mWantsTime = t; } - bool wantsTime() { return mWantsTime; } std::string message(int n) { @@ -82,8 +81,6 @@ namespace tut private: typedef std::vector MessageVector; MessageVector mMessages; - - bool mWantsTime; }; struct ErrorTestData @@ -144,8 +141,8 @@ namespace tut void ErrorTestObject::test<1>() // basic test of output { - llinfos << "test" << llendl; - llinfos << "bob" << llendl; + LL_INFOS() << "test" << LL_ENDL; + LL_INFOS() << "bob" << LL_ENDL; ensure_message_contains(0, "test"); ensure_message_contains(1, "bob"); @@ -156,11 +153,11 @@ namespace { void writeSome() { - lldebugs << "one" << llendl; - llinfos << "two" << llendl; - llwarns << "three" << llendl; - llerrs << "four" << llendl; - // fatal messages write out and addtional "error" message + LL_DEBUGS() << "one" << LL_ENDL; + LL_INFOS() << "two" << LL_ENDL; + LL_WARNS() << "three" << LL_ENDL; + // fatal messages write out an additional "error" message + LL_ERRS() << "four" << LL_ENDL; } }; @@ -259,19 +256,20 @@ namespace std::string writeReturningLocation() { - llinfos << "apple" << llendl; int this_line = __LINE__; + LL_INFOS() << "apple" << LL_ENDL; int this_line = __LINE__; return locationString(this_line); } - std::string writeReturningLocationAndFunction() + void writeReturningLocationAndFunction(std::string& location, std::string& function) { - llinfos << "apple" << llendl; int this_line = __LINE__; - return locationString(this_line) + __FUNCTION__; + LL_INFOS() << "apple" << LL_ENDL; int this_line = __LINE__; + location = locationString(this_line); + function = __FUNCTION__; } std::string errorReturningLocation() { - llerrs << "die" << llendl; int this_line = __LINE__; + LL_ERRS() << "die" << LL_ENDL; int this_line = __LINE__; return locationString(this_line); } } @@ -306,13 +304,13 @@ namespace tut std::string logFromGlobal(bool id) { - llinfos << (id ? "logFromGlobal: " : "") << "hi" << llendl; + LL_INFOS() << (id ? "logFromGlobal: " : "") << "hi" << LL_ENDL; return "logFromGlobal"; } static std::string logFromStatic(bool id) { - llinfos << (id ? "logFromStatic: " : "") << "hi" << llendl; + LL_INFOS() << (id ? "logFromStatic: " : "") << "hi" << LL_ENDL; return "logFromStatic"; } @@ -320,7 +318,7 @@ namespace { std::string logFromAnon(bool id) { - llinfos << (id ? "logFromAnon: " : "") << "hi" << llendl; + LL_INFOS() << (id ? "logFromAnon: " : "") << "hi" << LL_ENDL; return "logFromAnon"; } } @@ -328,7 +326,7 @@ namespace namespace Foo { std::string logFromNamespace(bool id) { - llinfos << (id ? "Foo::logFromNamespace: " : "") << "hi" << llendl; + LL_INFOS() << (id ? "Foo::logFromNamespace: " : "") << "hi" << LL_ENDL; //return "Foo::logFromNamespace"; // there is no standard way to get the namespace name, hence // we won't be testing for it @@ -342,12 +340,12 @@ namespace public: std::string logFromMember(bool id) { - llinfos << (id ? "ClassWithNoLogType::logFromMember: " : "") << "hi" << llendl; + LL_INFOS() << (id ? "ClassWithNoLogType::logFromMember: " : "") << "hi" << LL_ENDL; return "ClassWithNoLogType::logFromMember"; } static std::string logFromStatic(bool id) { - llinfos << (id ? "ClassWithNoLogType::logFromStatic: " : "") << "hi" << llendl; + LL_INFOS() << (id ? "ClassWithNoLogType::logFromStatic: " : "") << "hi" << LL_ENDL; return "ClassWithNoLogType::logFromStatic"; } }; @@ -357,12 +355,12 @@ namespace public: std::string logFromMember(bool id) { - llinfos << (id ? "ClassWithLogType::logFromMember: " : "") << "hi" << llendl; + LL_INFOS() << (id ? "ClassWithLogType::logFromMember: " : "") << "hi" << LL_ENDL; return "ClassWithLogType::logFromMember"; } static std::string logFromStatic(bool id) { - llinfos << (id ? "ClassWithLogType::logFromStatic: " : "") << "hi" << llendl; + LL_INFOS() << (id ? "ClassWithLogType::logFromStatic: " : "") << "hi" << LL_ENDL; return "ClassWithLogType::logFromStatic"; } }; @@ -434,19 +432,19 @@ namespace { std::string innerLogger() { - llinfos << "inside" << llendl; + LL_INFOS() << "inside" << LL_ENDL; return "moo"; } std::string outerLogger() { - llinfos << "outside(" << innerLogger() << ")" << llendl; + LL_INFOS() << "outside(" << innerLogger() << ")" << LL_ENDL; return "bar"; } void uberLogger() { - llinfos << "uber(" << outerLogger() << "," << innerLogger() << ")" << llendl; + LL_INFOS() << "uber(" << outerLogger() << "," << innerLogger() << ")" << LL_ENDL; } class LogWhileLogging @@ -454,7 +452,7 @@ namespace public: void print(std::ostream& out) const { - llinfos << "logging" << llendl; + LL_INFOS() << "logging" << LL_ENDL; out << "baz"; } }; @@ -465,7 +463,7 @@ namespace void metaLogger() { LogWhileLogging l; - llinfos << "meta(" << l << ")" << llendl; + LL_INFOS() << "meta(" << l << ")" << LL_ENDL; } } @@ -495,7 +493,7 @@ namespace tut } template<> template<> - // special handling of llerrs calls + // special handling of LL_ERRS() calls void ErrorTestObject::test<8>() { LLError::setPrintLocation(false); @@ -518,7 +516,7 @@ namespace void ufoSighting() { - llinfos << "ufo" << llendl; + LL_INFOS() << "ufo" << LL_ENDL; } } @@ -548,11 +546,13 @@ namespace tut LLError::setPrintLocation(true); LLError::setTimeFunction(roswell); mRecorder->setWantsTime(true); - std::string locationAndFunction = writeReturningLocationAndFunction(); + std::string location, + function; + writeReturningLocationAndFunction(location, function); - ensure_equals("order is time type location function message", + ensure_equals("order is location time type function message", mRecorder->message(0), - roswell() + " INFO: " + locationAndFunction + ": apple"); + location + roswell() + " INFO: " + function + ": apple"); } template<> template<> @@ -562,7 +562,7 @@ namespace tut TestRecorder* altRecorder(new TestRecorder); LLError::addRecorder(altRecorder); - llinfos << "boo" << llendl; + LL_INFOS() << "boo" << LL_ENDL; ensure_message_contains(0, "boo"); ensure_equals("alt recorder count", altRecorder->countMessages(), 1); @@ -574,7 +574,7 @@ namespace tut anotherRecorder->setWantsTime(true); LLError::addRecorder(anotherRecorder); - llinfos << "baz" << llendl; + LL_INFOS() << "baz" << LL_ENDL; std::string when = roswell(); @@ -590,10 +590,10 @@ class TestAlpha { LOG_CLASS(TestAlpha); public: - static void doDebug() { lldebugs << "add dice" << llendl; } - static void doInfo() { llinfos << "any idea" << llendl; } - static void doWarn() { llwarns << "aim west" << llendl; } - static void doError() { llerrs << "ate eels" << llendl; } + static void doDebug() { LL_DEBUGS() << "add dice" << LL_ENDL; } + static void doInfo() { LL_INFOS() << "any idea" << LL_ENDL; } + static void doWarn() { LL_WARNS() << "aim west" << LL_ENDL; } + static void doError() { LL_ERRS() << "ate eels" << LL_ENDL; } static void doAll() { doDebug(); doInfo(); doWarn(); doError(); } }; @@ -601,10 +601,10 @@ class TestBeta { LOG_CLASS(TestBeta); public: - static void doDebug() { lldebugs << "bed down" << llendl; } - static void doInfo() { llinfos << "buy iron" << llendl; } - static void doWarn() { llwarns << "bad word" << llendl; } - static void doError() { llerrs << "big easy" << llendl; } + static void doDebug() { LL_DEBUGS() << "bed down" << LL_ENDL; } + static void doInfo() { LL_INFOS() << "buy iron" << LL_ENDL; } + static void doWarn() { LL_WARNS() << "bad word" << LL_ENDL; } + static void doError() { LL_ERRS() << "big easy" << LL_ENDL; } static void doAll() { doDebug(); doInfo(); doWarn(); doError(); } }; diff --git a/indra/llcommon/tests/llsdserialize_test.cpp b/indra/llcommon/tests/llsdserialize_test.cpp index 4d436e8897..235008a5ae 100755 --- a/indra/llcommon/tests/llsdserialize_test.cpp +++ b/indra/llcommon/tests/llsdserialize_test.cpp @@ -268,7 +268,7 @@ namespace tut { std::stringstream stream; mFormatter->format(v, stream); - //llinfos << "checkRoundTrip: length " << stream.str().length() << llendl; + //LL_INFOS() << "checkRoundTrip: length " << stream.str().length() << LL_ENDL; LLSD w; mParser->reset(); // reset() call is needed since test code re-uses mParser mParser->parse(stream, w, stream.str().size()); diff --git a/indra/llcommon/tests/llunits_test.cpp b/indra/llcommon/tests/llunits_test.cpp index e631f18ad4..ff981ca2ff 100644 --- a/indra/llcommon/tests/llunits_test.cpp +++ b/indra/llcommon/tests/llunits_test.cpp @@ -53,6 +53,7 @@ namespace tut template<> template<> void units_object_t::test<1>() { + LL_INFOS("test") << "Test" << LL_ENDL; LLUnit float_quatloos; ensure(float_quatloos == 0.f); @@ -93,6 +94,11 @@ namespace tut LLUnit solari(quatloos); ensure(solari == 4096); + + // division of integral unit + LLUnit single_quatloo(1); + LLUnit quarter_latinum = single_quatloo; + ensure(quarter_latinum == 0.25f); } // conversions across non-base units -- cgit v1.2.3 From 9faaa28f4445425e8c5b7b002faffbe0365b905d Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 13 Aug 2013 18:33:07 -0700 Subject: SH-4346 FIX Interesting: some integer Statistics are displayed as floating point after crossing region boundary fine-tuned heuristics for switching between mean and current values in stat bar display added comments to LLUnits unit test --- indra/llcommon/tests/llunits_test.cpp | 76 ++++++++++++++--------------------- 1 file changed, 31 insertions(+), 45 deletions(-) (limited to 'indra/llcommon/tests') diff --git a/indra/llcommon/tests/llunits_test.cpp b/indra/llcommon/tests/llunits_test.cpp index ff981ca2ff..b0309585aa 100644 --- a/indra/llcommon/tests/llunits_test.cpp +++ b/indra/llcommon/tests/llunits_test.cpp @@ -53,30 +53,29 @@ namespace tut template<> template<> void units_object_t::test<1>() { - LL_INFOS("test") << "Test" << LL_ENDL; LLUnit float_quatloos; - ensure(float_quatloos == 0.f); + ensure("default float unit is zero", float_quatloos == 0.f); LLUnit float_initialize_quatloos(1); - ensure(float_initialize_quatloos == 1.f); + ensure("non-zero initialized unit", float_initialize_quatloos == 1.f); LLUnit int_quatloos; - ensure(int_quatloos == 0); + ensure("default int unit is zero", int_quatloos == 0); int_quatloos = 42; - ensure(int_quatloos == 42); + ensure("int assignment is preserved", int_quatloos == 42); float_quatloos = int_quatloos; - ensure(float_quatloos == 42.f); + ensure("float assignment from int preserves value", float_quatloos == 42.f); int_quatloos = float_quatloos; - ensure(int_quatloos == 42); + ensure("int assignment from float preserves value", int_quatloos == 42); float_quatloos = 42.1f; - ensure(float_quatloos == 42.1f); int_quatloos = float_quatloos; - ensure(int_quatloos == 42); + ensure("int units truncate float units on assignment", int_quatloos == 42); + LLUnit unsigned_int_quatloos(float_quatloos); - ensure(unsigned_int_quatloos == 42); + ensure("unsigned int can be initialized from signed int", unsigned_int_quatloos == 42); } // conversions to/from base unit @@ -84,36 +83,35 @@ namespace tut void units_object_t::test<2>() { LLUnit quatloos(1.f); - ensure(quatloos == 1.f); LLUnit latinum_bars(quatloos); - ensure(latinum_bars == 1.f / 4.f); + ensure("conversion between units is automatic via initialization", latinum_bars == 1.f / 4.f); latinum_bars = 256; quatloos = latinum_bars; - ensure(quatloos == 1024); - - LLUnit solari(quatloos); - ensure(solari == 4096); + ensure("conversion between units is automatic via assignment, and bidirectional", quatloos == 1024); - // division of integral unit LLUnit single_quatloo(1); LLUnit quarter_latinum = single_quatloo; - ensure(quarter_latinum == 0.25f); + ensure("division of integer unit preserves fractional values when converted to float unit", quarter_latinum == 0.25f); } // conversions across non-base units template<> template<> void units_object_t::test<3>() { - LLUnit solari = 4.f; + LLUnit quatloos(1024); + LLUnit solari(quatloos); + ensure("conversions can work between indirectly related units: Quatloos -> Latinum -> Solari", solari == 4096); + LLUnit latinum_bars = solari; - ensure(latinum_bars == 0.25f); + ensure("Non base units can be converted between each other", latinum_bars == 256); } // math operations template<> template<> void units_object_t::test<4>() { + // exercise math operations LLUnit quatloos = 1.f; quatloos *= 4.f; ensure(quatloos == 4); @@ -142,44 +140,34 @@ namespace tut quatloos -= 4.f; ensure(quatloos == 16); - quatloos *= 2.f; - ensure(quatloos == 32); - quatloos = quatloos * 2.f; - ensure(quatloos == 64); - quatloos = 0.5f * quatloos; - ensure(quatloos == 32); - quatloos /= 2.f; - ensure(quatloos == 16); + ensure(quatloos == 8); quatloos = quatloos / 4; - ensure(quatloos == 4); + ensure(quatloos == 2); - F32 ratio = quatloos / LLUnit(4.f); + F32 ratio = quatloos / LLUnit(2.f); ensure(ratio == 1); - ratio = quatloos / LLUnit(16.f); + ratio = quatloos / LLUnit(8.f); ensure(ratio == 1); - quatloos += LLUnit(4.f); - ensure(quatloos == 5); + quatloos += LLUnit(8.f); + ensure(quatloos == 4); quatloos -= LLUnit(1.f); - ensure(quatloos == 1); + ensure(quatloos == 0); } // implicit units template<> template<> void units_object_t::test<5>() { - // 0-initialized LLUnit quatloos; - // initialize implicit unit from explicit LLUnitImplicit quatloos_implicit = quatloos + 1; - ensure(quatloos_implicit == 1); + ensure("can initialize implicit unit from explicit", quatloos_implicit == 1); - // assign implicit to explicit, or perform math operations quatloos = quatloos_implicit; - ensure(quatloos == 1); + ensure("can assign implicit unit to explicit unit", quatloos == 1); quatloos += quatloos_implicit; - ensure(quatloos == 2); + ensure("can perform math operation using mixture of implicit and explicit units", quatloos == 2); // math operations on implicits quatloos_implicit = 1; @@ -211,15 +199,13 @@ namespace tut // implicit conversion to POD F32 float_val = quatloos_implicit; - ensure(float_val == 16); + ensure("implicit units convert implicitly to regular values", float_val == 16); S32 int_val = quatloos_implicit; - ensure(int_val == 16); + ensure("implicit units convert implicitly to regular values", int_val == 16); // conversion of implicits LLUnitImplicit latinum_implicit(2); - ensure(latinum_implicit == 2); - - ensure(latinum_implicit * 2 == quatloos_implicit); + ensure("implicit units of different types are comparable", latinum_implicit * 2 == quatloos_implicit); } } -- cgit v1.2.3 From 26581404e426b00cd0a07c38b5cb858d5d5faa28 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 14 Aug 2013 11:51:49 -0700 Subject: BUILDFIX: added header for numeric_limits support on gcc added convenience types for units F32Seconds, etc. --- indra/llcommon/tests/llunits_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/tests') diff --git a/indra/llcommon/tests/llunits_test.cpp b/indra/llcommon/tests/llunits_test.cpp index b0309585aa..8546bcbc54 100644 --- a/indra/llcommon/tests/llunits_test.cpp +++ b/indra/llcommon/tests/llunits_test.cpp @@ -112,7 +112,7 @@ namespace tut void units_object_t::test<4>() { // exercise math operations - LLUnit quatloos = 1.f; + LLUnit quatloos(1.f); quatloos *= 4.f; ensure(quatloos == 4); quatloos = quatloos * 2; -- cgit v1.2.3 From 612892b45a3413b16e40c49d3bfde77a4ca927fd Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sun, 18 Aug 2013 22:30:27 -0700 Subject: SH-4433 WIP: Interesting: Statistics > Ping Sim is always 0 ms continued conversion to units system made units perform type promotion correctly and preserve type in arithmetic e.g. can now do LLVector3 in units added typedefs for remaining common unit types, including implicits --- indra/llcommon/tests/llunits_test.cpp | 126 ++++++++++++++++++++++------------ 1 file changed, 82 insertions(+), 44 deletions(-) (limited to 'indra/llcommon/tests') diff --git a/indra/llcommon/tests/llunits_test.cpp b/indra/llcommon/tests/llunits_test.cpp index 8546bcbc54..a8e9be86ca 100644 --- a/indra/llcommon/tests/llunits_test.cpp +++ b/indra/llcommon/tests/llunits_test.cpp @@ -38,6 +38,13 @@ namespace LLUnits LL_DECLARE_DERIVED_UNIT(Latinum, / 16, Solari, "Sol"); } +typedef LLUnit F32Quatloos; +typedef LLUnit S32Quatloos; +typedef LLUnit F32Latinum; +typedef LLUnit S32Latinum; +typedef LLUnit F32Solari; +typedef LLUnit S32Solari; + namespace tut { using namespace LLUnits; @@ -54,28 +61,28 @@ namespace tut void units_object_t::test<1>() { LLUnit float_quatloos; - ensure("default float unit is zero", float_quatloos == 0.f); + ensure("default float unit is zero", float_quatloos == F32Quatloos(0.f)); LLUnit float_initialize_quatloos(1); - ensure("non-zero initialized unit", float_initialize_quatloos == 1.f); + ensure("non-zero initialized unit", float_initialize_quatloos == F32Quatloos(1.f)); LLUnit int_quatloos; - ensure("default int unit is zero", int_quatloos == 0); + ensure("default int unit is zero", int_quatloos == S32Quatloos(0)); - int_quatloos = 42; - ensure("int assignment is preserved", int_quatloos == 42); + int_quatloos = S32Quatloos(42); + ensure("int assignment is preserved", int_quatloos == S32Quatloos(42)); float_quatloos = int_quatloos; - ensure("float assignment from int preserves value", float_quatloos == 42.f); + ensure("float assignment from int preserves value", float_quatloos == F32Quatloos(42.f)); int_quatloos = float_quatloos; - ensure("int assignment from float preserves value", int_quatloos == 42); + ensure("int assignment from float preserves value", int_quatloos == S32Quatloos(42)); - float_quatloos = 42.1f; + float_quatloos = F32Quatloos(42.1f); int_quatloos = float_quatloos; - ensure("int units truncate float units on assignment", int_quatloos == 42); + ensure("int units truncate float units on assignment", int_quatloos == S32Quatloos(42)); LLUnit unsigned_int_quatloos(float_quatloos); - ensure("unsigned int can be initialized from signed int", unsigned_int_quatloos == 42); + ensure("unsigned int can be initialized from signed int", unsigned_int_quatloos == S32Quatloos(42)); } // conversions to/from base unit @@ -84,15 +91,15 @@ namespace tut { LLUnit quatloos(1.f); LLUnit latinum_bars(quatloos); - ensure("conversion between units is automatic via initialization", latinum_bars == 1.f / 4.f); + ensure("conversion between units is automatic via initialization", latinum_bars == F32Latinum(1.f / 4.f)); - latinum_bars = 256; + latinum_bars = S32Latinum(256); quatloos = latinum_bars; - ensure("conversion between units is automatic via assignment, and bidirectional", quatloos == 1024); + ensure("conversion between units is automatic via assignment, and bidirectional", quatloos == S32Quatloos(1024)); LLUnit single_quatloo(1); LLUnit quarter_latinum = single_quatloo; - ensure("division of integer unit preserves fractional values when converted to float unit", quarter_latinum == 0.25f); + ensure("division of integer unit preserves fractional values when converted to float unit", quarter_latinum == F32Latinum(0.25f)); } // conversions across non-base units @@ -101,10 +108,10 @@ namespace tut { LLUnit quatloos(1024); LLUnit solari(quatloos); - ensure("conversions can work between indirectly related units: Quatloos -> Latinum -> Solari", solari == 4096); + ensure("conversions can work between indirectly related units: Quatloos -> Latinum -> Solari", solari == S32Solari(4096)); LLUnit latinum_bars = solari; - ensure("Non base units can be converted between each other", latinum_bars == 256); + ensure("Non base units can be converted between each other", latinum_bars == S32Latinum(256)); } // math operations @@ -114,36 +121,36 @@ namespace tut // exercise math operations LLUnit quatloos(1.f); quatloos *= 4.f; - ensure(quatloos == 4); + ensure(quatloos == S32Quatloos(4)); quatloos = quatloos * 2; - ensure(quatloos == 8); + ensure(quatloos == S32Quatloos(8)); quatloos = 2.f * quatloos; - ensure(quatloos == 16); - - quatloos += 4.f; - ensure(quatloos == 20); - quatloos += 4; - ensure(quatloos == 24); - quatloos = quatloos + 4; - ensure(quatloos == 28); - quatloos = 4 + quatloos; - ensure(quatloos == 32); + ensure(quatloos == S32Quatloos(16)); + + quatloos += F32Quatloos(4.f); + ensure(quatloos == S32Quatloos(20)); + quatloos += S32Quatloos(4); + ensure(quatloos == S32Quatloos(24)); + quatloos = quatloos + S32Quatloos(4); + ensure(quatloos == S32Quatloos(28)); + quatloos = S32Quatloos(4) + quatloos; + ensure(quatloos == S32Quatloos(32)); quatloos += quatloos * 3; - ensure(quatloos == 128); + ensure(quatloos == S32Quatloos(128)); quatloos -= quatloos / 4 * 3; - ensure(quatloos == 32); - quatloos = quatloos - 8; - ensure(quatloos == 24); - quatloos -= 4; - ensure(quatloos == 20); - quatloos -= 4.f; - ensure(quatloos == 16); + ensure(quatloos == S32Quatloos(32)); + quatloos = quatloos - S32Quatloos(8); + ensure(quatloos == S32Quatloos(24)); + quatloos -= S32Quatloos(4); + ensure(quatloos == S32Quatloos(20)); + quatloos -= F32Quatloos(4.f); + ensure(quatloos == S32Quatloos(16)); quatloos /= 2.f; - ensure(quatloos == 8); + ensure(quatloos == S32Quatloos(8)); quatloos = quatloos / 4; - ensure(quatloos == 2); + ensure(quatloos == S32Quatloos(2)); F32 ratio = quatloos / LLUnit(2.f); ensure(ratio == 1); @@ -151,23 +158,54 @@ namespace tut ensure(ratio == 1); quatloos += LLUnit(8.f); - ensure(quatloos == 4); + ensure(quatloos == S32Quatloos(4)); quatloos -= LLUnit(1.f); - ensure(quatloos == 0); + ensure(quatloos == S32Quatloos(0)); } - // implicit units + // comparison operators template<> template<> void units_object_t::test<5>() + { + LLUnit quatloos(1); + ensure("can perform less than comparison against same type", quatloos < S32Quatloos(2)); + ensure("can perform less than comparison against different storage type", quatloos < F32Quatloos(2.f)); + ensure("can perform less than comparison against different units", quatloos < S32Latinum(5)); + ensure("can perform less than comparison against different storage type and units", quatloos < F32Latinum(5.f)); + + ensure("can perform greater than comparison against same type", quatloos > S32Quatloos(0)); + ensure("can perform greater than comparison against different storage type", quatloos > F32Quatloos(0.f)); + ensure("can perform greater than comparison against different units", quatloos > S32Latinum(0)); + ensure("can perform greater than comparison against different storage type and units", quatloos > F32Latinum(0.f)); + + } + + bool accept_explicit_quatloos(S32Quatloos q) + { + return true; + } + + // signature compatibility + template<> template<> + void units_object_t::test<6>() + { + S32Quatloos quatloos(1); + ensure("can pass unit values as argument", accept_explicit_quatloos(S32Quatloos(1))); + ensure("can pass unit values as argument", accept_explicit_quatloos(quatloos)); + } + + // implicit units + template<> template<> + void units_object_t::test<7>() { LLUnit quatloos; - LLUnitImplicit quatloos_implicit = quatloos + 1; + LLUnitImplicit quatloos_implicit = quatloos + S32Quatloos(1); ensure("can initialize implicit unit from explicit", quatloos_implicit == 1); quatloos = quatloos_implicit; - ensure("can assign implicit unit to explicit unit", quatloos == 1); + ensure("can assign implicit unit to explicit unit", quatloos == S32Quatloos(1)); quatloos += quatloos_implicit; - ensure("can perform math operation using mixture of implicit and explicit units", quatloos == 2); + ensure("can perform math operation using mixture of implicit and explicit units", quatloos == S32Quatloos(2)); // math operations on implicits quatloos_implicit = 1; -- cgit v1.2.3 From 2c6bc5afa59a88136fd6de4ebf0cb99ea7cdef3f Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 21 Aug 2013 14:06:57 -0700 Subject: SH-4433 WIP Interesting: Statistics > Ping Sim is always 0 ms made getPrimaryAccumulator return a reference since it was an always non-null pointer changed unit conversion to perform lazy division in order to avoid truncation of timer values --- indra/llcommon/tests/llunits_test.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'indra/llcommon/tests') diff --git a/indra/llcommon/tests/llunits_test.cpp b/indra/llcommon/tests/llunits_test.cpp index a8e9be86ca..b8aef9d15e 100644 --- a/indra/llcommon/tests/llunits_test.cpp +++ b/indra/llcommon/tests/llunits_test.cpp @@ -38,12 +38,9 @@ namespace LLUnits LL_DECLARE_DERIVED_UNIT(Latinum, / 16, Solari, "Sol"); } -typedef LLUnit F32Quatloos; -typedef LLUnit S32Quatloos; -typedef LLUnit F32Latinum; -typedef LLUnit S32Latinum; -typedef LLUnit F32Solari; -typedef LLUnit S32Solari; +LL_DECLARE_UNIT_TYPEDEFS(LLUnits, Quatloos); +LL_DECLARE_UNIT_TYPEDEFS(LLUnits, Latinum); +LL_DECLARE_UNIT_TYPEDEFS(LLUnits, Solari); namespace tut { @@ -83,6 +80,15 @@ namespace tut LLUnit unsigned_int_quatloos(float_quatloos); ensure("unsigned int can be initialized from signed int", unsigned_int_quatloos == S32Quatloos(42)); + + S32Solari int_solari(1); + + float_quatloos = int_solari; + ensure("fractional units are preserved in conversion from integer to float type", float_quatloos == F32Quatloos(0.25f)); + + int_quatloos = S32Quatloos(1); + F32Solari float_solari = int_quatloos; + ensure("can convert with fractional intermediates from integer to float type", float_solari == F32Solari(4.f)); } // conversions to/from base unit @@ -185,6 +191,11 @@ namespace tut return true; } + bool accept_implicit_quatloos(S32Quatloos q) + { + return true; + } + // signature compatibility template<> template<> void units_object_t::test<6>() -- cgit v1.2.3 From 049317fc6442e8b2c2d93309a9d759aa063d2010 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 21 Aug 2013 23:51:46 -0700 Subject: SH-4433 WIP Interesting: Statistics > Ping Sim is always 0 ms added unit tests for lltrace --- indra/llcommon/tests/lltrace_test.cpp | 141 ++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 indra/llcommon/tests/lltrace_test.cpp (limited to 'indra/llcommon/tests') diff --git a/indra/llcommon/tests/lltrace_test.cpp b/indra/llcommon/tests/lltrace_test.cpp new file mode 100644 index 0000000000..1c2a4528ae --- /dev/null +++ b/indra/llcommon/tests/lltrace_test.cpp @@ -0,0 +1,141 @@ +/** + * @file llsingleton_test.cpp + * @date 2011-08-11 + * @brief Unit test for the LLSingleton class + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "linden_common.h" + +#include "lltrace.h" +#include "lltracethreadrecorder.h" +#include "lltracerecording.h" +#include "../test/lltut.h" + +namespace LLUnits +{ + // using powers of 2 to allow strict floating point equality + LL_DECLARE_BASE_UNIT(Ounces, "oz"); + LL_DECLARE_DERIVED_UNIT(Ounces, * 12, TallCup, ""); + LL_DECLARE_DERIVED_UNIT(Ounces, * 16, GrandeCup, ""); + LL_DECLARE_DERIVED_UNIT(Ounces, * 20, VentiCup, ""); + + LL_DECLARE_BASE_UNIT(Grams, "g"); + LL_DECLARE_DERIVED_UNIT(Grams, / 1000, Milligrams, "mg"); +} + +LL_DECLARE_UNIT_TYPEDEFS(LLUnits, Ounces); +LL_DECLARE_UNIT_TYPEDEFS(LLUnits, TallCup); +LL_DECLARE_UNIT_TYPEDEFS(LLUnits, GrandeCup); +LL_DECLARE_UNIT_TYPEDEFS(LLUnits, VentiCup); +LL_DECLARE_UNIT_TYPEDEFS(LLUnits, Grams); +LL_DECLARE_UNIT_TYPEDEFS(LLUnits, Milligrams); + + +namespace tut +{ + using namespace LLTrace; + struct trace + { + ThreadRecorder mRecorder; + }; + + typedef test_group trace_t; + typedef trace_t::object trace_object_t; + tut::trace_t tut_singleton("LLTrace"); + + static CountStatHandle sCupsOfCoffeeConsumed("coffeeconsumed", "Delicious cup of dark roast."); + static SampleStatHandle sCaffeineLevelStat("caffeinelevel", "Coffee buzz quotient"); + static EventStatHandle sOuncesPerCup("cupsize", "Large, huge, or ginormous"); + + static F32 sCaffeineLevel(0.f); + const F32Milligrams sCaffeinePerOz(18.f); + + void drink_coffee(S32 num_cups, S32Ounces cup_size) + { + add(sCupsOfCoffeeConsumed, num_cups); + for (S32 i = 0; i < num_cups; i++) + { + record(sOuncesPerCup, cup_size); + } + + sCaffeineLevel += F32Ounces(num_cups * cup_size).value() * sCaffeinePerOz.value(); + sample(sCaffeineLevelStat, sCaffeineLevel); + } + + // basic data collection + template<> template<> + void trace_object_t::test<1>() + { + sample(sCaffeineLevelStat, sCaffeineLevel); + + Recording all_day; + Recording at_work; + Recording after_3pm; + + all_day.start(); + { + // warm up with one grande cup + drink_coffee(1, S32TallCup(1)); + + // go to work + at_work.start(); + { + // drink 3 tall cups, 1 after 3 pm + drink_coffee(2, S32GrandeCup(1)); + after_3pm.start(); + drink_coffee(1, S32GrandeCup(1)); + } + at_work.stop(); + drink_coffee(1, S32VentiCup(1)); + } + after_3pm.stop(); + all_day.stop(); + + ensure("count stats are counted when recording is active", + at_work.getSum(sCupsOfCoffeeConsumed) == 3 + && all_day.getSum(sCupsOfCoffeeConsumed) == 5 + && after_3pm.getSum(sCupsOfCoffeeConsumed) == 2); + ensure("measurement sums are counted when recording is active", + at_work.getSum(sOuncesPerCup) == S32Ounces(48) + && all_day.getSum(sOuncesPerCup) == S32Ounces(80) + && after_3pm.getSum(sOuncesPerCup) == S32Ounces(36)); + ensure("measurement min is specific to when recording is active", + at_work.getMin(sOuncesPerCup) == S32GrandeCup(1) + && all_day.getMin(sOuncesPerCup) == S32TallCup(1) + && after_3pm.getMin(sOuncesPerCup) == S32GrandeCup(1)); + ensure("measurement max is specific to when recording is active", + at_work.getMax(sOuncesPerCup) == S32GrandeCup(1) + && all_day.getMax(sOuncesPerCup) == S32VentiCup(1) + && after_3pm.getMax(sOuncesPerCup) == S32VentiCup(1)); + ensure("sample min is specific to when recording is active", + at_work.getMin(sCaffeineLevelStat) == sCaffeinePerOz * ((S32Ounces)S32TallCup(1)).value() + && all_day.getMin(sCaffeineLevelStat) == F32Milligrams(0.f) + && after_3pm.getMin(sCaffeineLevelStat) == sCaffeinePerOz * ((S32Ounces)S32TallCup(1) + (S32Ounces)S32GrandeCup(2)).value()); + ensure("sample max is specific to when recording is active", + at_work.getMax(sCaffeineLevelStat) == sCaffeinePerOz * ((S32Ounces)S32TallCup(1) + (S32Ounces)S32GrandeCup(3)).value() + && all_day.getMax(sCaffeineLevelStat) == sCaffeinePerOz * ((S32Ounces)S32TallCup(1) + (S32Ounces)S32GrandeCup(3) + (S32Ounces)S32VentiCup(1)).value() + && after_3pm.getMax(sCaffeineLevelStat) == sCaffeinePerOz * ((S32Ounces)S32TallCup(1) + (S32Ounces)S32GrandeCup(3) + (S32Ounces)S32VentiCup(1)).value()); + } + +} -- cgit v1.2.3 From cf014375b8b408d58bd35deb4e58e4369fb3bf62 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 22 Aug 2013 14:21:16 -0700 Subject: SH-4433 FIX: Interesting: Statistics > Ping Sim is always 0 ms removed bad assert fixed precision issues during int->unsigned int conversions and vice versa --- indra/llcommon/tests/llunits_test.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'indra/llcommon/tests') diff --git a/indra/llcommon/tests/llunits_test.cpp b/indra/llcommon/tests/llunits_test.cpp index b8aef9d15e..292c6122af 100644 --- a/indra/llcommon/tests/llunits_test.cpp +++ b/indra/llcommon/tests/llunits_test.cpp @@ -257,4 +257,20 @@ namespace tut LLUnitImplicit latinum_implicit(2); ensure("implicit units of different types are comparable", latinum_implicit * 2 == quatloos_implicit); } + + // precision tests + template<> template<> + void units_object_t::test<8>() + { + U32Bytes max_bytes(U32_MAX); + S32Megabytes mega_bytes = max_bytes; + ensure("max available precision is used when converting units", mega_bytes == (S32Megabytes)4095); + + mega_bytes = (S32Megabytes)-5 + (U32Megabytes)1; + ensure("can mix signed and unsigned in units addition", mega_bytes == (S32Megabytes)-4); + + mega_bytes = (U32Megabytes)5 + (S32Megabytes)-1; + ensure("can mix unsigned and signed in units addition", mega_bytes == (S32Megabytes)4); + + } } -- cgit v1.2.3 From a77f42494584537489410a5157179aaadf868935 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 23 Aug 2013 13:41:51 -0700 Subject: BUILDFIX: fix for crashes in unit tests on mac and linux --- indra/llcommon/tests/llleap_test.cpp | 3 --- indra/llcommon/tests/llprocess_test.cpp | 3 --- indra/llcommon/tests/llsdserialize_test.cpp | 4 +--- 3 files changed, 1 insertion(+), 9 deletions(-) (limited to 'indra/llcommon/tests') diff --git a/indra/llcommon/tests/llleap_test.cpp b/indra/llcommon/tests/llleap_test.cpp index 29060d4ef5..9ea822cb8d 100755 --- a/indra/llcommon/tests/llleap_test.cpp +++ b/indra/llcommon/tests/llleap_test.cpp @@ -22,7 +22,6 @@ // other Linden headers #include "../test/lltut.h" #include "../test/namedtempfile.h" -#include "../test/manageapr.h" #include "../test/catch_and_store_what_in.h" #include "wrapllerrs.h" #include "llevents.h" @@ -33,8 +32,6 @@ using boost::assign::list_of; -static ManageAPR manager; - StringVec sv(const StringVec& listof) { return listof; } #if defined(LL_WINDOWS) diff --git a/indra/llcommon/tests/llprocess_test.cpp b/indra/llcommon/tests/llprocess_test.cpp index f188865eb0..50b5c79e71 100755 --- a/indra/llcommon/tests/llprocess_test.cpp +++ b/indra/llcommon/tests/llprocess_test.cpp @@ -29,7 +29,6 @@ //#include // other Linden headers #include "../test/lltut.h" -#include "../test/manageapr.h" #include "../test/namedtempfile.h" #include "../test/catch_and_store_what_in.h" #include "stringize.h" @@ -47,8 +46,6 @@ //namespace lambda = boost::lambda; -// static instance of this manages APR init/cleanup -static ManageAPR manager; /***************************************************************************** * Helpers diff --git a/indra/llcommon/tests/llsdserialize_test.cpp b/indra/llcommon/tests/llsdserialize_test.cpp index 235008a5ae..b5893135ea 100755 --- a/indra/llcommon/tests/llsdserialize_test.cpp +++ b/indra/llcommon/tests/llsdserialize_test.cpp @@ -56,12 +56,9 @@ namespace lambda = boost::lambda; #include "../llformat.h" #include "../test/lltut.h" -#include "../test/manageapr.h" #include "../test/namedtempfile.h" #include "stringize.h" -static ManageAPR manager; - std::vector string_to_vector(const std::string& str) { return std::vector(str.begin(), str.end()); @@ -1723,5 +1720,6 @@ namespace tut "This string\n" "has several\n" "lines."); + } } -- cgit v1.2.3 From 4c7f4896290707c833f5e088963c94ff5e01acde Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 23 Aug 2013 15:02:37 -0700 Subject: BUILDFIX: replaced function that was accidentally removed --- indra/llcommon/tests/llprocess_test.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'indra/llcommon/tests') diff --git a/indra/llcommon/tests/llprocess_test.cpp b/indra/llcommon/tests/llprocess_test.cpp index 50b5c79e71..709a095105 100755 --- a/indra/llcommon/tests/llprocess_test.cpp +++ b/indra/llcommon/tests/llprocess_test.cpp @@ -45,7 +45,12 @@ #endif //namespace lambda = boost::lambda; - + std::string apr_strerror_helper(apr_status_t rv) +{ + char errbuf[256]; + apr_strerror(rv, errbuf, sizeof(errbuf)); + return errbuf; +} /***************************************************************************** * Helpers @@ -57,7 +62,7 @@ #define aprchk(expr) aprchk_(#expr, (expr)) static void aprchk_(const char* call, apr_status_t rv, apr_status_t expected=APR_SUCCESS) { - tut::ensure_equals(STRINGIZE(call << " => " << rv << ": " << manager.strerror(rv)), + tut::ensure_equals(STRINGIZE(call << " => " << rv << ": " << apr_strerror_helper(rv)), rv, expected); } -- cgit v1.2.3 From 8535b87544cc2e71896716a4cd1c3c2445ff4af0 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 26 Aug 2013 18:00:24 -0700 Subject: removed some unecessary template parameters from LLUnit member functions forced unit conversion code to inline unit conversion now no longer converts all the way to base and back, but tries to find equivalent units as early as possible fixed another llinfos instance scene monitor now outputs n/a for invalid samples --- indra/llcommon/tests/llunits_test.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/llcommon/tests') diff --git a/indra/llcommon/tests/llunits_test.cpp b/indra/llcommon/tests/llunits_test.cpp index 292c6122af..31d4f86159 100644 --- a/indra/llcommon/tests/llunits_test.cpp +++ b/indra/llcommon/tests/llunits_test.cpp @@ -271,6 +271,5 @@ namespace tut mega_bytes = (U32Megabytes)5 + (S32Megabytes)-1; ensure("can mix unsigned and signed in units addition", mega_bytes == (S32Megabytes)4); - } } -- cgit v1.2.3 From 0b96a0e80c34067056811d100fd5d4e7404e07b5 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 26 Aug 2013 18:37:07 -0700 Subject: BUILDFIX: corrected template parameter for LL_BAD_TEMPLATE_INSTANTIATION macro in llunit --- indra/llcommon/tests/llprocess_test.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/llcommon/tests') diff --git a/indra/llcommon/tests/llprocess_test.cpp b/indra/llcommon/tests/llprocess_test.cpp index 709a095105..e09692c82d 100755 --- a/indra/llcommon/tests/llprocess_test.cpp +++ b/indra/llcommon/tests/llprocess_test.cpp @@ -62,7 +62,8 @@ #define aprchk(expr) aprchk_(#expr, (expr)) static void aprchk_(const char* call, apr_status_t rv, apr_status_t expected=APR_SUCCESS) { - tut::ensure_equals(STRINGIZE(call << " => " << rv << ": " << apr_strerror_helper(rv)), + tut::ensure_equals(STRINGIZE(call << " => " << rv << ": " << apr_strerror_helper + (rv)), rv, expected); } -- cgit v1.2.3 From a7aed07a5b620977fb74e4070e432eef01d11d3c Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 27 Aug 2013 13:41:19 -0700 Subject: broke out llunit.h into llunittype.h and llunits.h for unit declarations changed unit declarations macros to make a lot more sense --- indra/llcommon/tests/lltrace_test.cpp | 8 ++-- indra/llcommon/tests/llunits_test.cpp | 73 +++++++++++++++++++++++++++++++++-- 2 files changed, 74 insertions(+), 7 deletions(-) (limited to 'indra/llcommon/tests') diff --git a/indra/llcommon/tests/lltrace_test.cpp b/indra/llcommon/tests/lltrace_test.cpp index 1c2a4528ae..8ce509699d 100644 --- a/indra/llcommon/tests/lltrace_test.cpp +++ b/indra/llcommon/tests/lltrace_test.cpp @@ -36,12 +36,12 @@ namespace LLUnits { // using powers of 2 to allow strict floating point equality LL_DECLARE_BASE_UNIT(Ounces, "oz"); - LL_DECLARE_DERIVED_UNIT(Ounces, * 12, TallCup, ""); - LL_DECLARE_DERIVED_UNIT(Ounces, * 16, GrandeCup, ""); - LL_DECLARE_DERIVED_UNIT(Ounces, * 20, VentiCup, ""); + LL_DECLARE_DERIVED_UNIT(TallCup, "", Ounces, / 12); + LL_DECLARE_DERIVED_UNIT(GrandeCup, "", Ounces, / 16); + LL_DECLARE_DERIVED_UNIT(VentiCup, "", Ounces, / 20); LL_DECLARE_BASE_UNIT(Grams, "g"); - LL_DECLARE_DERIVED_UNIT(Grams, / 1000, Milligrams, "mg"); + LL_DECLARE_DERIVED_UNIT(Milligrams, "mg", Grams, * 1000); } LL_DECLARE_UNIT_TYPEDEFS(LLUnits, Ounces); diff --git a/indra/llcommon/tests/llunits_test.cpp b/indra/llcommon/tests/llunits_test.cpp index 31d4f86159..5a18603e4e 100644 --- a/indra/llcommon/tests/llunits_test.cpp +++ b/indra/llcommon/tests/llunits_test.cpp @@ -27,15 +27,15 @@ #include "linden_common.h" -#include "llunit.h" +#include "llunits.h" #include "../test/lltut.h" namespace LLUnits { // using powers of 2 to allow strict floating point equality LL_DECLARE_BASE_UNIT(Quatloos, "Quat"); - LL_DECLARE_DERIVED_UNIT(Quatloos, * 4, Latinum, "Lat"); - LL_DECLARE_DERIVED_UNIT(Latinum, / 16, Solari, "Sol"); + LL_DECLARE_DERIVED_UNIT(Latinum, "Lat", Quatloos, / 4); + LL_DECLARE_DERIVED_UNIT(Solari, "Sol", Latinum, * 16); } LL_DECLARE_UNIT_TYPEDEFS(LLUnits, Quatloos); @@ -256,6 +256,12 @@ namespace tut // conversion of implicits LLUnitImplicit latinum_implicit(2); ensure("implicit units of different types are comparable", latinum_implicit * 2 == quatloos_implicit); + + quatloos_implicit += F32Quatloos(10); + ensure("can add-assign explicit units", quatloos_implicit == 26); + + quatloos_implicit -= F32Quatloos(10); + ensure("can subtract-assign explicit units", quatloos_implicit == 16); } // precision tests @@ -272,4 +278,65 @@ namespace tut mega_bytes = (U32Megabytes)5 + (S32Megabytes)-1; ensure("can mix unsigned and signed in units addition", mega_bytes == (S32Megabytes)4); } + + // default units + template<> template<> + void units_object_t::test<9>() + { + U32Gigabytes GB(1); + U32Megabytes MB(GB); + U32Kilobytes KB(GB); + U32Bytes B(GB); + + ensure("GB -> MB conversion", MB.value() == 1024); + ensure("GB -> KB conversion", KB.value() == 1024 * 1024); + ensure("GB -> B conversion", B.value() == 1024 * 1024 * 1024); + + KB = U32Kilobytes(1); + U32Kilobits Kb(KB); + U32Bits b(KB); + ensure("KB -> Kb conversion", Kb.value() == 8); + ensure("KB -> b conversion", b.value() == 8 * 1024); + + U32Days days(1); + U32Hours hours(days); + U32Minutes minutes(days); + U32Seconds seconds(days); + U32Milliseconds ms(days); + + ensure("days -> hours conversion", hours.value() == 24); + ensure("days -> minutes conversion", minutes.value() == 24 * 60); + ensure("days -> seconds conversion", seconds.value() == 24 * 60 * 60); + ensure("days -> ms conversion", ms.value() == 24 * 60 * 60 * 1000); + + U32Kilometers km(1); + U32Meters m(km); + U32Centimeters cm(km); + U32Millimeters mm(km); + + ensure("km -> m conversion", m.value() == 1000); + ensure("km -> cm conversion", cm.value() == 1000 * 100); + ensure("km -> mm conversion", mm.value() == 1000 * 1000); + + U32Gigahertz GHz(1); + U32Megahertz MHz(GHz); + U32Kilohertz KHz(GHz); + U32Hertz Hz(GHz); + + ensure("GHz -> MHz conversion", MHz.value() == 1000); + ensure("GHz -> KHz conversion", KHz.value() == 1000 * 1000); + ensure("GHz -> Hz conversion", Hz.value() == 1000 * 1000 * 1000); + + F32Radians rad(6.2831853071795f); + F32Degrees deg(rad); + ensure("radians -> degrees conversion", deg.value() > 359 && deg.value() < 361); + + F32Percent percent(50); + F32Ratio ratio(percent); + ensure("percent -> ratio conversion", ratio.value() == 0.5f); + + U32Kilotriangles ktris(1); + U32Triangles tris(ktris); + ensure("kilotriangles -> triangles conversion", tris.value() == 1000); + } } -- cgit v1.2.3 From 00bd492b30f0dcb49d354be74e6e9a312a84863f Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 27 Aug 2013 16:36:36 -0700 Subject: got linear unit conversions (like fahrenheit <-> celsius) working correctly further optimizations for codegen --- indra/llcommon/tests/llunits_test.cpp | 40 +++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) (limited to 'indra/llcommon/tests') diff --git a/indra/llcommon/tests/llunits_test.cpp b/indra/llcommon/tests/llunits_test.cpp index 5a18603e4e..59876ce3b4 100644 --- a/indra/llcommon/tests/llunits_test.cpp +++ b/indra/llcommon/tests/llunits_test.cpp @@ -42,6 +42,18 @@ LL_DECLARE_UNIT_TYPEDEFS(LLUnits, Quatloos); LL_DECLARE_UNIT_TYPEDEFS(LLUnits, Latinum); LL_DECLARE_UNIT_TYPEDEFS(LLUnits, Solari); +namespace LLUnits +{ + LL_DECLARE_BASE_UNIT(Celcius, "c"); + LL_DECLARE_DERIVED_UNIT(Fahrenheit, "f", Celcius, * 9 / 5 + 32); + LL_DECLARE_DERIVED_UNIT(Kelvin, "k", Celcius, + 273.15f); +} + +LL_DECLARE_UNIT_TYPEDEFS(LLUnits, Celcius); +LL_DECLARE_UNIT_TYPEDEFS(LLUnits, Fahrenheit); +LL_DECLARE_UNIT_TYPEDEFS(LLUnits, Kelvin); + + namespace tut { using namespace LLUnits; @@ -328,8 +340,8 @@ namespace tut ensure("GHz -> Hz conversion", Hz.value() == 1000 * 1000 * 1000); F32Radians rad(6.2831853071795f); - F32Degrees deg(rad); - ensure("radians -> degrees conversion", deg.value() > 359 && deg.value() < 361); + S32Degrees deg(rad); + ensure("radians -> degrees conversion", deg.value() == 360); F32Percent percent(50); F32Ratio ratio(percent); @@ -339,4 +351,28 @@ namespace tut U32Triangles tris(ktris); ensure("kilotriangles -> triangles conversion", tris.value() == 1000); } + + bool value_near(F32 value, F32 target, F32 threshold) + { + return fabsf(value - target) < threshold; + } + + // linear transforms + template<> template<> + void units_object_t::test<10>() + { + F32Celcius float_celcius(100); + F32Fahrenheit float_fahrenheit(float_celcius); + ensure("floating point celcius -> fahrenheit conversion using linear transform", value_near(float_fahrenheit.value(), 212, 0.1f) ); + + float_celcius = float_fahrenheit; + ensure("floating point fahrenheit -> celcius conversion using linear transform (round trip)", value_near(float_celcius.value(), 100.f, 0.1f) ); + + S32Celcius int_celcius(100); + S32Fahrenheit int_fahrenheit(int_celcius); + ensure("integer celcius -> fahrenheit conversion using linear transform", int_fahrenheit.value() == 212); + + int_celcius = int_fahrenheit; + ensure("integer fahrenheit -> celcius conversion using linear transform (round trip)", int_celcius.value() == 100); + } } -- cgit v1.2.3 From 25e2fbe419655b2f8ce22dbafa1de6bc655b1567 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 27 Aug 2013 18:08:32 -0700 Subject: got comparisons between implicit and explicit units working right --- indra/llcommon/tests/llunits_test.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'indra/llcommon/tests') diff --git a/indra/llcommon/tests/llunits_test.cpp b/indra/llcommon/tests/llunits_test.cpp index 59876ce3b4..d5b7c08672 100644 --- a/indra/llcommon/tests/llunits_test.cpp +++ b/indra/llcommon/tests/llunits_test.cpp @@ -274,6 +274,16 @@ namespace tut quatloos_implicit -= F32Quatloos(10); ensure("can subtract-assign explicit units", quatloos_implicit == 16); + + // comparisons + ensure("can compare greater than implicit unit", quatloos_implicit > F32QuatloosImplicit(0.f)); + ensure("can compare greater than non-implicit unit", quatloos_implicit > F32Quatloos(0.f)); + ensure("can compare greater than or equal to implicit unit", quatloos_implicit >= F32QuatloosImplicit(0.f)); + ensure("can compare greater than or equal to non-implicit unit", quatloos_implicit >= F32Quatloos(0.f)); + ensure("can compare less than implicit unit", quatloos_implicit < F32QuatloosImplicit(0.f)); + ensure("can compare less than non-implicit unit", quatloos_implicit < F32Quatloos(0.f)); + ensure("can compare less than or equal to implicit unit", quatloos_implicit <= F32QuatloosImplicit(0.f)); + ensure("can compare less than or equal to non-implicit unit", quatloos_implicit <= F32Quatloos(0.f)); } // precision tests -- cgit v1.2.3 From 5ddd5694b54150b50a77627112ea98a4a94d0e46 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 27 Aug 2013 18:59:32 -0700 Subject: fixed bad logic in unit test --- indra/llcommon/tests/llunits_test.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/llcommon/tests') diff --git a/indra/llcommon/tests/llunits_test.cpp b/indra/llcommon/tests/llunits_test.cpp index d5b7c08672..57cf9810af 100644 --- a/indra/llcommon/tests/llunits_test.cpp +++ b/indra/llcommon/tests/llunits_test.cpp @@ -280,10 +280,10 @@ namespace tut ensure("can compare greater than non-implicit unit", quatloos_implicit > F32Quatloos(0.f)); ensure("can compare greater than or equal to implicit unit", quatloos_implicit >= F32QuatloosImplicit(0.f)); ensure("can compare greater than or equal to non-implicit unit", quatloos_implicit >= F32Quatloos(0.f)); - ensure("can compare less than implicit unit", quatloos_implicit < F32QuatloosImplicit(0.f)); - ensure("can compare less than non-implicit unit", quatloos_implicit < F32Quatloos(0.f)); - ensure("can compare less than or equal to implicit unit", quatloos_implicit <= F32QuatloosImplicit(0.f)); - ensure("can compare less than or equal to non-implicit unit", quatloos_implicit <= F32Quatloos(0.f)); + ensure("can compare less than implicit unit", quatloos_implicit < F32QuatloosImplicit(20.f)); + ensure("can compare less than non-implicit unit", quatloos_implicit < F32Quatloos(20.f)); + ensure("can compare less than or equal to implicit unit", quatloos_implicit <= F32QuatloosImplicit(20.f)); + ensure("can compare less than or equal to non-implicit unit", quatloos_implicit <= F32Quatloos(20.f)); } // precision tests -- cgit v1.2.3 From 4170ef8ecc604da38482934fb864adc5b436739f Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 18 Oct 2013 09:50:26 -0700 Subject: fixed llinstancetracker unit test --- indra/llcommon/tests/llinstancetracker_test.cpp | 17 +++++++++-------- indra/llcommon/tests/wrapllerrs.h | 8 ++++---- 2 files changed, 13 insertions(+), 12 deletions(-) (limited to 'indra/llcommon/tests') diff --git a/indra/llcommon/tests/llinstancetracker_test.cpp b/indra/llcommon/tests/llinstancetracker_test.cpp index e769c3e22c..601d28ea3e 100755 --- a/indra/llcommon/tests/llinstancetracker_test.cpp +++ b/indra/llcommon/tests/llinstancetracker_test.cpp @@ -194,20 +194,21 @@ namespace tut { set_test_name("delete Keyed with outstanding instance_iter"); std::string what; - Keyed* keyed = new Keyed("one"); + Keyed* keyed = new Keyed("delete Keyed with outstanding instance_iter"); { - WrapLL_ERRS wrapper; + WrapLLErrs wrapper; Keyed::instance_iter i(Keyed::beginInstances()); try { delete keyed; } - catch (const WrapLL_ERRS::FatalException& e) + catch (const WrapLLErrs::FatalException& e) { what = e.what(); } } ensure(! what.empty()); + delete keyed; } template<> template<> @@ -215,15 +216,15 @@ namespace tut { set_test_name("delete Keyed with outstanding key_iter"); std::string what; - Keyed* keyed = new Keyed("one"); + Keyed* keyed = new Keyed("delete Keyed with outstanding key_it"); { - WrapLL_ERRS wrapper; + WrapLLErrs wrapper; Keyed::key_iter i(Keyed::beginKeys()); try { delete keyed; } - catch (const WrapLL_ERRS::FatalException& e) + catch (const WrapLLErrs::FatalException& e) { what = e.what(); } @@ -238,13 +239,13 @@ namespace tut std::string what; Unkeyed* unkeyed = new Unkeyed; { - WrapLL_ERRS wrapper; + WrapLLErrs wrapper; Unkeyed::instance_iter i(Unkeyed::beginInstances()); try { delete unkeyed; } - catch (const WrapLL_ERRS::FatalException& e) + catch (const WrapLLErrs::FatalException& e) { what = e.what(); } diff --git a/indra/llcommon/tests/wrapllerrs.h b/indra/llcommon/tests/wrapllerrs.h index a4d3a4e026..3137bd8fea 100755 --- a/indra/llcommon/tests/wrapllerrs.h +++ b/indra/llcommon/tests/wrapllerrs.h @@ -46,9 +46,9 @@ // replicate, but better to reuse extern void wouldHaveCrashed(const std::string& message); -struct WrapLL_ERRS +struct WrapLLErrs { - WrapLL_ERRS(): + WrapLLErrs(): // Resetting Settings discards the default Recorder that writes to // stderr. Otherwise, expected llerrs (LL_ERRS) messages clutter the // console output of successful tests, potentially confusing things. @@ -57,10 +57,10 @@ struct WrapLL_ERRS mPriorFatal(LLError::getFatalFunction()) { // Make LL_ERRS call our own operator() method - LLError::setFatalFunction(boost::bind(&WrapLL_ERRS::operator(), this, _1)); + LLError::setFatalFunction(boost::bind(&WrapLLErrs::operator(), this, _1)); } - ~WrapLL_ERRS() + ~WrapLLErrs() { LLError::setFatalFunction(mPriorFatal); LLError::restoreSettings(mPriorErrorSettings); -- cgit v1.2.3 From aef2a527e5ff13db9078c980bfa099bc4bde4124 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 21 Oct 2013 10:32:19 -0700 Subject: BUILDFIX: double delete in instancetracker unit test --- indra/llcommon/tests/llinstancetracker_test.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/llcommon/tests') diff --git a/indra/llcommon/tests/llinstancetracker_test.cpp b/indra/llcommon/tests/llinstancetracker_test.cpp index 601d28ea3e..c7d4b8a06b 100755 --- a/indra/llcommon/tests/llinstancetracker_test.cpp +++ b/indra/llcommon/tests/llinstancetracker_test.cpp @@ -208,7 +208,6 @@ namespace tut } } ensure(! what.empty()); - delete keyed; } template<> template<> -- cgit v1.2.3 From 30863e0af01945c6aad22ea89d64c6f3167b4bd6 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 21 Oct 2013 11:19:38 -0700 Subject: another attempted buildfix --- indra/llcommon/tests/lleventdispatcher_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/tests') diff --git a/indra/llcommon/tests/lleventdispatcher_test.cpp b/indra/llcommon/tests/lleventdispatcher_test.cpp index 263c9b171f..5a4df81bf1 100755 --- a/indra/llcommon/tests/lleventdispatcher_test.cpp +++ b/indra/llcommon/tests/lleventdispatcher_test.cpp @@ -312,7 +312,7 @@ namespace tut { struct lleventdispatcher_data { - WrapLL_ERRS redirect; + WrapLLErrs redirect; Dispatcher work; Vars v; std::string name, desc; -- cgit v1.2.3 From 318a1eca57d2e4ee3a0845c137f48e721cc57b00 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 21 Oct 2013 11:24:35 -0700 Subject: more buildfix stuff --- indra/llcommon/tests/lleventfilter_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llcommon/tests') diff --git a/indra/llcommon/tests/lleventfilter_test.cpp b/indra/llcommon/tests/lleventfilter_test.cpp index ca05ef62a9..2cdfb52f2f 100755 --- a/indra/llcommon/tests/lleventfilter_test.cpp +++ b/indra/llcommon/tests/lleventfilter_test.cpp @@ -244,7 +244,7 @@ namespace tut void filter_object::test<4>() { set_test_name("LLEventTimeout::errorAfter()"); - WrapLL_ERRS capture; + WrapLLErrs capture; LLEventPump& driver(pumps.obtain("driver")); TestEventTimeout filter(driver); listener0.reset(0); @@ -274,7 +274,7 @@ namespace tut { mainloop.post(17); } - catch (const WrapLL_ERRS::FatalException& e) + catch (const WrapLLErrs::FatalException& e) { threw = e.what(); } -- cgit v1.2.3 From fcf5602ba82015cc4ab40734b97a7b8c9085d2d6 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 21 Oct 2013 11:56:31 -0700 Subject: more buildfix --- indra/llcommon/tests/lleventcoro_test.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/llcommon/tests') diff --git a/indra/llcommon/tests/lleventcoro_test.cpp b/indra/llcommon/tests/lleventcoro_test.cpp index 5ebde1a31d..cb5e15eff2 100755 --- a/indra/llcommon/tests/lleventcoro_test.cpp +++ b/indra/llcommon/tests/lleventcoro_test.cpp @@ -346,13 +346,13 @@ namespace tut LLCoroEventPumps waiter; replyName = waiter.getName0(); errorName = waiter.getName1(); - WrapLL_ERRS capture; + WrapLLErrs capture; try { result = waiter.waitWithLog(self); debug("no exception"); } - catch (const WrapLL_ERRS::FatalException& e) + catch (const WrapLLErrs::FatalException& e) { debug(STRINGIZE("exception " << e.what())); threw = e.what(); @@ -436,7 +436,7 @@ namespace tut BEGIN { LLCoroEventPumps waiter; - WrapLL_ERRS capture; + WrapLLErrs capture; try { result = waiter.postAndWaitWithLog(self, @@ -444,7 +444,7 @@ namespace tut immediateAPI.getPump(), "reply", "error"); debug("no exception"); } - catch (const WrapLL_ERRS::FatalException& e) + catch (const WrapLLErrs::FatalException& e) { debug(STRINGIZE("exception " << e.what())); threw = e.what(); -- cgit v1.2.3 From 1dfba44b3dc14564c99333dedb7a380a160aee44 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 21 Oct 2013 14:22:21 -0700 Subject: fixed things so that trace recordings can be read from even while active --- indra/llcommon/tests/lltrace_test.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'indra/llcommon/tests') diff --git a/indra/llcommon/tests/lltrace_test.cpp b/indra/llcommon/tests/lltrace_test.cpp index 8ce509699d..0a9d85ad00 100644 --- a/indra/llcommon/tests/lltrace_test.cpp +++ b/indra/llcommon/tests/lltrace_test.cpp @@ -109,8 +109,9 @@ namespace tut at_work.stop(); drink_coffee(1, S32VentiCup(1)); } - after_3pm.stop(); - all_day.stop(); + // don't need to stop recordings to get accurate values out of them + //after_3pm.stop(); + //all_day.stop(); ensure("count stats are counted when recording is active", at_work.getSum(sCupsOfCoffeeConsumed) == 3 -- cgit v1.2.3