calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / tools / qa / cppunit / test_bigint.cxx
blob140562df0e23a1799a85070a7ae99f5d415eff68
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <cppunit/TestFixture.h>
21 #include <cppunit/extensions/HelperMacros.h>
23 #include <tools/bigint.hxx>
25 namespace tools
27 class BigIntTest : public CppUnit::TestFixture
29 public:
30 void testConstructionFromLongLong();
32 CPPUNIT_TEST_SUITE(BigIntTest);
33 CPPUNIT_TEST(testConstructionFromLongLong);
34 CPPUNIT_TEST_SUITE_END();
37 void BigIntTest::testConstructionFromLongLong()
39 // small positive number
41 BigInt bi(static_cast<sal_Int64>(42));
42 CPPUNIT_ASSERT(!bi.IsZero());
43 CPPUNIT_ASSERT(!bi.IsNeg());
44 CPPUNIT_ASSERT(bi.IsLong());
45 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(42), static_cast<sal_Int32>(bi));
48 // small negative number
50 BigInt bi(static_cast<sal_Int64>(-42));
51 CPPUNIT_ASSERT(!bi.IsZero());
52 CPPUNIT_ASSERT(bi.IsNeg());
53 CPPUNIT_ASSERT(bi.IsLong());
54 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(-42), static_cast<sal_Int32>(bi));
57 #if SAL_TYPES_SIZEOFLONG < SAL_TYPES_SIZEOFLONGLONG
58 // positive number just fitting to sal_Int32
60 BigInt bi(static_cast<sal_Int64>(std::numeric_limits<sal_Int32>::max()));
61 CPPUNIT_ASSERT(!bi.IsZero());
62 CPPUNIT_ASSERT(!bi.IsNeg());
63 CPPUNIT_ASSERT(bi.IsLong());
64 CPPUNIT_ASSERT_EQUAL(std::numeric_limits<sal_Int32>::max(), static_cast<sal_Int32>(bi));
67 // negative number just fitting to sal_Int32
69 BigInt bi(static_cast<sal_Int64>(std::numeric_limits<sal_Int32>::min()));
70 CPPUNIT_ASSERT(!bi.IsZero());
71 CPPUNIT_ASSERT(bi.IsNeg());
72 CPPUNIT_ASSERT(bi.IsLong());
73 CPPUNIT_ASSERT_EQUAL(std::numeric_limits<sal_Int32>::min(), static_cast<sal_Int32>(bi));
76 // positive number not fitting to sal_Int32
78 BigInt bi(static_cast<sal_Int64>(std::numeric_limits<sal_Int32>::max()) + 1);
79 CPPUNIT_ASSERT(!bi.IsZero());
80 CPPUNIT_ASSERT(!bi.IsNeg());
81 CPPUNIT_ASSERT(!bi.IsLong());
84 // negative number not fitting to sal_Int32
86 BigInt bi(static_cast<sal_Int64>(std::numeric_limits<sal_Int32>::min()) - 1);
87 CPPUNIT_ASSERT(!bi.IsZero());
88 CPPUNIT_ASSERT(bi.IsNeg());
89 CPPUNIT_ASSERT(!bi.IsLong());
91 #endif
94 CPPUNIT_TEST_SUITE_REGISTRATION(BigIntTest);
97 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */