diff options
author | Jack Lloyd <[email protected]> | 2017-10-24 12:01:43 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-10-24 12:01:43 -0400 |
commit | 5c3470fee0d3e8a6c0eb702602364e9e5dd5d658 (patch) | |
tree | d40d1af9f123973447d7f56394b4eb16810ab603 /src/tests/test_mp.cpp | |
parent | da0a1124242e3a108819df58054e8dd909268a00 (diff) |
Avoid "using namespace" in test code
Diffstat (limited to 'src/tests/test_mp.cpp')
-rw-r--r-- | src/tests/test_mp.cpp | 58 |
1 files changed, 25 insertions, 33 deletions
diff --git a/src/tests/test_mp.cpp b/src/tests/test_mp.cpp index 8372e7e5c..766ba476f 100644 --- a/src/tests/test_mp.cpp +++ b/src/tests/test_mp.cpp @@ -35,17 +35,15 @@ class MP_Unit_Tests final : public Test { Result result("bigint_cnd_add"); - using namespace Botan; + const Botan::word max = Botan::MP_WORD_MAX; - const word max = MP_WORD_MAX; - - word a = 2; - word c = bigint_cnd_add(0, &a, &max, 1); + Botan::word a = 2; + Botan::word c = Botan::bigint_cnd_add(0, &a, &max, 1); result.test_int_eq(a, 2, "No op"); result.test_int_eq(c, 0, "No op"); - c = bigint_cnd_add(1, &a, &max, 1); + c = Botan::bigint_cnd_add(1, &a, &max, 1); result.test_int_eq(a, 1, "Add"); result.test_int_eq(c, 1, "Carry"); @@ -59,18 +57,16 @@ class MP_Unit_Tests final : public Test { Result result("bigint_cnd_sub"); - using namespace Botan; - - word a = 2; - word b = 3; - word c = bigint_cnd_sub(0, &a, &b, 1); + Botan::word a = 2; + Botan::word b = 3; + Botan::word c = Botan::bigint_cnd_sub(0, &a, &b, 1); result.test_int_eq(a, 2, "No op"); result.test_int_eq(c, 0, "No op"); - c = bigint_cnd_sub(1, &a, &b, 1); + c = Botan::bigint_cnd_sub(1, &a, &b, 1); - result.test_int_eq(a, MP_WORD_MAX, "Sub"); + result.test_int_eq(a, Botan::MP_WORD_MAX, "Sub"); result.test_int_eq(c, 1, "Borrow"); return result; @@ -80,27 +76,25 @@ class MP_Unit_Tests final : public Test { Result result("bigint_cnd_abs"); - using namespace Botan; - - word x1 = MP_WORD_MAX; - bigint_cnd_abs(1, &x1, 1); + Botan::word x1 = Botan::MP_WORD_MAX; + Botan::bigint_cnd_abs(1, &x1, 1); result.test_int_eq(x1, 1, "Abs"); x1 = 0; - bigint_cnd_abs(1, &x1, 1); + Botan::bigint_cnd_abs(1, &x1, 1); result.test_int_eq(x1, 0, "Abs"); x1 = 1; - bigint_cnd_abs(1, &x1, 1); - result.test_int_eq(x1, MP_WORD_MAX, "Abs"); + Botan::bigint_cnd_abs(1, &x1, 1); + result.test_int_eq(x1, Botan::MP_WORD_MAX, "Abs"); x1 = 1; - bigint_cnd_abs(0, &x1, 1); + Botan::bigint_cnd_abs(0, &x1, 1); result.test_int_eq(x1, 1, "No change"); - word x2[2] = { MP_WORD_MAX, MP_WORD_MAX }; + Botan::word x2[2] = { Botan::MP_WORD_MAX, Botan::MP_WORD_MAX }; - bigint_cnd_abs(1, x2, 2); + Botan::bigint_cnd_abs(1, x2, 2); result.test_int_eq(x2[0], 1, "Abs"); result.test_int_eq(x2[1], 0, "Abs"); @@ -111,24 +105,22 @@ class MP_Unit_Tests final : public Test { Result result("bigint_cnd_swap"); - using namespace Botan; - // null with zero length is ok - bigint_cnd_swap(0, nullptr, nullptr, 0); - bigint_cnd_swap(1, nullptr, nullptr, 0); + Botan::bigint_cnd_swap(0, nullptr, nullptr, 0); + Botan::bigint_cnd_swap(1, nullptr, nullptr, 0); - word x1 = 5, y1 = 9; + Botan::word x1 = 5, y1 = 9; - bigint_cnd_swap(0, &x1, &y1, 1); + Botan::bigint_cnd_swap(0, &x1, &y1, 1); result.test_int_eq(x1, 5, "No swap"); - bigint_cnd_swap(1, &x1, &y1, 1); + Botan::bigint_cnd_swap(1, &x1, &y1, 1); result.test_int_eq(x1, 9, "Swap"); - word x5[5] = { 0, 1, 2, 3, 4 }; - word y5[5] = { 3, 2, 1, 0, 9 }; + Botan::word x5[5] = { 0, 1, 2, 3, 4 }; + Botan::word y5[5] = { 3, 2, 1, 0, 9 }; // Should only modify first four - bigint_cnd_swap(1, x5, y5, 4); + Botan::bigint_cnd_swap(1, x5, y5, 4); for(size_t i = 0; i != 4; ++i) { |