mirror of
https://github.com/monero-project/monero.git
synced 2024-12-25 22:49:24 -05:00
a79734c848
Includes performance tests
62 lines
2.2 KiB
C++
62 lines
2.2 KiB
C++
// Copyright (c) 2024, The Monero Project
|
|
//
|
|
// All rights reserved.
|
|
//
|
|
// Redistribution and use in source and binary forms, with or without modification, are
|
|
// permitted provided that the following conditions are met:
|
|
//
|
|
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
|
// conditions and the following disclaimer.
|
|
//
|
|
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
// of conditions and the following disclaimer in the documentation and/or other
|
|
// materials provided with the distribution.
|
|
//
|
|
// 3. Neither the name of the copyright holder nor the names of its contributors may be
|
|
// used to endorse or promote products derived from this software without specific
|
|
// prior written permission.
|
|
//
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
|
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
|
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
|
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
#pragma once
|
|
|
|
#include "cryptonote_basic/cryptonote_format_utils.h"
|
|
|
|
class test_is_valid_decomposed_amount
|
|
{
|
|
public:
|
|
static const size_t loop_count = 3;
|
|
static const uint64_t max_per_loop = 1000000000; // must be power of 10
|
|
|
|
bool init()
|
|
{
|
|
m_num_valid_per_loop = 1;
|
|
uint64_t x = 1;
|
|
while (x != max_per_loop)
|
|
{
|
|
m_num_valid_per_loop += 9;
|
|
x *= 10;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
bool test()
|
|
{
|
|
size_t num_valid = 0;
|
|
for (uint64_t a = 0; a <= max_per_loop; ++a)
|
|
num_valid += cryptonote::is_valid_decomposed_amount(a);
|
|
return num_valid == m_num_valid_per_loop;
|
|
}
|
|
|
|
size_t m_num_valid_per_loop;
|
|
};
|