ultimatepp/autotest/Algo/Algo.cpp
cxl dfc5163d5f .autotest
git-svn-id: svn://ultimatepp.org/upp/trunk@9765 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2016-05-02 21:13:08 +00:00

29 lines
725 B
C++

#include <Core/Core.h>
using namespace Upp;
#define Check(a, b) if(a != b) { DLOG(#a << "=" << a << " != " << b); NEVER(); }
CONSOLE_APP_MAIN
{
StdLogSetup(LOG_COUT|LOG_FILE);
Vector<int> x;
x << 1 << 5 << 4 << 3 << 2 << 10;
// 0 1 2 3 4 5
Check(FindMin(SubRange(x, 0, 2)), 0);
Check(FindMax(SubRange(x, 0, 3)), 1);
Check(FindMax(SubRange(x, 2, 3)) + 2, 2);
Check(FindMax(SubRange(x, 2, 4)) + 2, 5);
Check(FindMin(SubRange(x, 2, 4)) + 2, 4);
Sort(x);
Check(FindBinary(x, 1), 0);
Check(FindBinary(x, 2), 1);
Check(FindBinary(x, 7), -1);
Check(FindBinary(x, 0), -1);
Check(FindBinary(x, 11), -1);
Check(FindBinary(x, 10), 5);
LOG("================ OK");
}