Skip to content

Commit

Permalink
Move some global variables from main.cpp to TestGlobals.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
fwojcik committed Aug 29, 2023
1 parent 93b814b commit 3953856
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 15 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ add_library(
util/Stats.cpp
util/VCode.cpp
util/Wordlist.cpp
util/TestGlobals.cpp
#
tests/SanityTest.cpp
tests/AvalancheTest.cpp
Expand Down
15 changes: 0 additions & 15 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,21 +105,6 @@
#include <cerrno>
#include <clocale>

//-----------------------------------------------------------------------------
// Globally-visible configuration
HashInfo::endianness g_hashEndian = HashInfo::ENDIAN_DEFAULT;
uint64_t g_seed = 0;

//--------
// What each test suite prints upon failure
const char * g_failstr = "*********FAIL*********\n";

//--------
// Overall log2-p-value statistics and test pass/fail counts
uint32_t g_log2pValueCounts[COUNT_MAX_PVALUE + 2];
uint32_t g_testPass, g_testFail;
std::vector<std::pair<const char *, char *>> g_testFailures;

//-----------------------------------------------------------------------------
// Locally-visible configuration
static bool g_drawDiagram = false;
Expand Down
80 changes: 80 additions & 0 deletions util/TestGlobals.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* SMHasher3
* Copyright (C) 2021-2022 Frank J. T. Wojcik
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program 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
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see
* <https://www.gnu.org/licenses/>.
*
* This file incorporates work covered by the following copyright and
* permission notice:
*
* Copyright (c) 2010-2012 Austin Appleby
* Copyright (c) 2014-2021 Reini Urban
* Copyright (c) 2015 Ivan Kruglov
* Copyright (c) 2015 Paul G
* Copyright (c) 2016 Jason Schulz
* Copyright (c) 2016-2018 Leonid Yuriev
* Copyright (c) 2016 Sokolov Yura aka funny_falcon
* Copyright (c) 2016 Vlad Egorov
* Copyright (c) 2018 Jody Bruchon
* Copyright (c) 2019 Niko Rebenich
* Copyright (c) 2019-2020 Yann Collet
* Copyright (c) 2019-2021 data-man
* Copyright (c) 2019 王一 WangYi
* Copyright (c) 2020 Cris Stringfellow
* Copyright (c) 2020 HashTang
* Copyright (c) 2020 Jim Apple
* Copyright (c) 2020 Thomas Dybdahl Ahle
* Copyright (c) 2020 Tom Kaitchuck
* Copyright (c) 2021 Logan oos Even
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "Platform.h"
#include "Hashinfo.h"
#include "TestGlobals.h"

//-----------------------------------------------------------------------------
// Globally-visible configuration
HashInfo::endianness g_hashEndian = HashInfo::ENDIAN_DEFAULT;
uint64_t g_seed = 0;

//--------
// What each test suite prints upon failure
const char * g_failstr = "*********FAIL*********\n";

//--------
// Overall log2-p-value statistics and test pass/fail counts
uint32_t g_log2pValueCounts[COUNT_MAX_PVALUE + 2];
uint32_t g_testPass, g_testFail;
std::vector<std::pair<const char *, char *>> g_testFailures;

0 comments on commit 3953856

Please sign in to comment.