ultimatepp/upptst/Ref/Ref.cpp
cxl 5f201e178c .upptst
git-svn-id: svn://ultimatepp.org/upp/trunk@4463 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2012-01-23 16:39:55 +00:00

42 lines
704 B
C++

#include <Core/Core.h>
using namespace Upp;
template <class T>
void TestRef(const T& x)
{
LOG(typeid(T).name());
T a;
Ref ref(a);
ref.SetValue(x);
ASSERT(a == x);
LOG(a);
Value xx = x;
if(!xx.Is<bool>()) {
ref.SetNull();
ASSERT(IsNull(a));
ASSERT(ref.IsNull());
ref.SetValue(Null);
ASSERT(IsNull(a));
ASSERT(ref.IsNull());
}
LOG("-------------------");
}
CONSOLE_APP_MAIN
{
TestRef(Date(2012, 3, 4));
TestRef(Time(2012, 3, 4, 23, 1));
TestRef(String("hello!"));
TestRef(WString("hello!"));
TestRef(true);
TestRef(123);
TestRef(123.456);
TestRef((int64)123);
int x;
Ref ref(x);
ref.SetValue(1.0);
DLOG(x);
ASSERT(x == 1);
}