1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773
|
// --------------------------------------------------------------------------
// OpenMS -- Open-Source Mass Spectrometry
// --------------------------------------------------------------------------
// Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
// ETH Zurich, and Freie Universitaet Berlin 2002-2013.
//
// This software is released under a three-clause BSD license:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * 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.
// * Neither the name of any author or any participating institution
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
// For a full list of authors, refer to the file AUTHORS.
// --------------------------------------------------------------------------
// 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 ANY OF THE AUTHORS OR THE CONTRIBUTING
// INSTITUTIONS 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.
//
// --------------------------------------------------------------------------
// $Maintainer: Stephan Aiche$
// $Authors: Marc Sturm $
// --------------------------------------------------------------------------
#include <OpenMS/CONCEPT/ClassTest.h>
///////////////////////////
#include <OpenMS/DATASTRUCTURES/DataValue.h>
#include <sstream>
// we ignore the -Wunused-value warning here, since we do not want the compiler
// to report problems like
// DataValue_test.C:285:3: warning: expression result unused [-Wunused-value]
// TEST_EXCEPTION(Exception::ConversionError, (StringList)DataValue("abc,ab"))
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-value"
#endif
///////////////////////////
START_TEST(DataValue, "$Id: DataValue_test.C 10915 2013-04-04 20:14:57Z aiche $")
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
using namespace OpenMS;
using namespace std;
// default ctor
DataValue* dv_ptr = 0;
DataValue* dv_nullPointer = 0;
START_SECTION((DataValue()))
dv_ptr = new DataValue;
TEST_NOT_EQUAL(dv_ptr, dv_nullPointer)
END_SECTION
// destructor
START_SECTION((virtual ~DataValue()))
delete dv_ptr;
END_SECTION
// ctor for all supported types a DataValue object can hold
START_SECTION((DataValue(long double)))
long double x = -3.4L;
DataValue d(x);
// Note: The implementation uses typedef DoubleReal (as opposed to float, double, long double.)
TEST_REAL_SIMILAR((DoubleReal)d, -3.4L)
END_SECTION
START_SECTION((DataValue(double)))
double x = -3.0;
DataValue d(x);
// Note: The implementation uses typedef DoubleReal (as opposed to float, double, long double.)
TEST_REAL_SIMILAR((DoubleReal)d, -3.0);
END_SECTION
START_SECTION((DataValue(float)))
float x = 3.0;
DataValue d(x);
// Note: The implementation uses typedef DoubleReal (as opposed to float, double, long double.)
TEST_REAL_SIMILAR((DoubleReal)d, 3.0);
END_SECTION
START_SECTION((DataValue(short int)))
short int n = -3000;
DataValue d(n);
TEST_EQUAL((short int)d, -3000)
END_SECTION
START_SECTION((DataValue(unsigned short int)))
unsigned short int n = 3000u;
DataValue d(n);
TEST_EQUAL((unsigned short)d, 3000u)
END_SECTION
START_SECTION((DataValue(int)))
int n = -3000;
DataValue d(n);
TEST_EQUAL((int)d, -3000)
END_SECTION
START_SECTION((DataValue(unsigned)))
unsigned int n = 3000u;
DataValue d(n);
TEST_EQUAL((unsigned int)d, 3000u)
END_SECTION
START_SECTION((DataValue(long int)))
long int n = -3000;
DataValue d(n);
TEST_EQUAL((long int)d, -3000)
END_SECTION
START_SECTION((DataValue(unsigned long)))
unsigned long int n = 3000u;
DataValue d(n);
TEST_EQUAL((unsigned long int)d, 3000u)
END_SECTION
START_SECTION((DataValue(long long)))
long long n = -3000;
DataValue d(n);
TEST_EQUAL((long long) d, -3000)
END_SECTION
START_SECTION((DataValue(unsigned long long)))
unsigned long long n = 3000;
DataValue d(n);
TEST_EQUAL((unsigned long long) d, 3000)
END_SECTION
START_SECTION((DataValue(const char*)))
const char* s = "test char";
DataValue d(s);
TEST_EQUAL((std::string)d, "test char")
END_SECTION
START_SECTION((DataValue(const std::string&)))
string s = "test string";
DataValue d(s);
TEST_EQUAL((String)d, "test string")
END_SECTION
START_SECTION((DataValue(const QString&)))
QString s = "test string";
DataValue d(s);
TEST_EQUAL((String)d, "test string")
END_SECTION
START_SECTION((DataValue(const String&)))
String s = "test string";
DataValue d(s);
TEST_EQUAL((String)d, "test string")
END_SECTION
START_SECTION((DataValue(const StringList &)))
StringList sl;
sl << "test string" << "test String 2";
DataValue d(sl);
TEST_EQUAL((StringList)d, sl)
END_SECTION
START_SECTION((DataValue(const IntList &)))
IntList il;
il << 1 <<2 ;
DataValue d(il);
TEST_EQUAL((IntList)d,il)
END_SECTION
START_SECTION((DataValue(const DoubleList &)))
DoubleList dl;
dl << 1.2 << 22.3333;
DataValue d(dl);
TEST_EQUAL((DoubleList)d,dl);
END_SECTION
// copy ctor
START_SECTION((DataValue(const DataValue&)))
DataValue p1((DoubleReal) 1.23);
DataValue p3((Real) 1.23);
DataValue p4((Int) -3);
DataValue p5((UInt) 123);
DataValue p6("test char");
DataValue p7(std::string("test string"));
DataValue p8(StringList::create("test string,string2,last string"));
DataValue p9;
DataValue p10(IntList::create("1,2,3,4,5"));
DataValue p11(DoubleList::create("1.2,2.3,3.4"));
DataValue copy_of_p1(p1);
DataValue copy_of_p3(p3);
DataValue copy_of_p4(p4);
DataValue copy_of_p5(p5);
DataValue copy_of_p6(p6);
DataValue copy_of_p7(p7);
DataValue copy_of_p8(p8);
DataValue copy_of_p9(p9);
DataValue copy_of_p10(p10);
DataValue copy_of_p11(p11);
TEST_REAL_SIMILAR( (DoubleReal) copy_of_p1, 1.23)
TEST_REAL_SIMILAR( (Real) copy_of_p3, 1.23)
TEST_EQUAL( (Int) copy_of_p4, -3)
TEST_EQUAL( (UInt) copy_of_p5, 123)
TEST_EQUAL( (std::string) copy_of_p6, "test char")
TEST_EQUAL( (std::string) copy_of_p7, "test string")
TEST_EQUAL( (StringList) copy_of_p8, StringList::create("test string,string2,last string"))
TEST_EQUAL( (copy_of_p9.isEmpty()),true)
TEST_EQUAL((IntList)copy_of_p10,IntList::create("1,2,3,4,5"))
TEST_EQUAL((DoubleList)copy_of_p11,DoubleList::create("1.2,2.3,3.4"))
END_SECTION
// assignment operator
START_SECTION((DataValue& operator = (const DataValue&)))
DataValue p1((DoubleReal) 1.23);
DataValue p3((Real) 1.23);
DataValue p4((Int) -3);
DataValue p5((UInt) 123);
DataValue p6("test char");
DataValue p7(std::string("test string"));
DataValue p8(StringList::create("test string,string2,last string"));
DataValue p9;
DataValue p10(IntList::create("1,2,3,4,5"));
DataValue p11(DoubleList::create("1.2,2.3,3.4"));
DataValue copy_of_p;
copy_of_p = p1;
TEST_REAL_SIMILAR( (DoubleReal) copy_of_p, 1.23)
copy_of_p = p3;
TEST_REAL_SIMILAR( (Real) copy_of_p, 1.23)
copy_of_p = p4;
TEST_EQUAL( (Int) copy_of_p, -3)
copy_of_p = p5;
TEST_EQUAL( (UInt) copy_of_p, 123)
copy_of_p = p6;
TEST_EQUAL( (std::string) copy_of_p, "test char")
copy_of_p = p7;
TEST_EQUAL( (std::string) copy_of_p, "test string")
copy_of_p = p8;
TEST_EQUAL( (StringList) copy_of_p, StringList::create("test string,string2,last string"))
copy_of_p = p9;
TEST_EQUAL( (copy_of_p.isEmpty()),true)
copy_of_p = p10;
TEST_EQUAL((IntList)copy_of_p,IntList::create("1,2,3,4,5"))
copy_of_p = p11;
TEST_EQUAL((DoubleList)copy_of_p,DoubleList::create("1.2,2.3,3.4"))
END_SECTION
// Is DataValue object empty?
START_SECTION((bool isEmpty() const))
DataValue p1;
bool res1 = p1.isEmpty();
TEST_NOT_EQUAL( res1, false)
DataValue p2((Real)1.2);
bool res2 = p2.isEmpty();
TEST_EQUAL( res2, false)
TEST_REAL_SIMILAR( (Real) p2, 1.2)
DataValue p4("2");
bool res4 = p4.isEmpty();
TEST_EQUAL( res4, false)
TEST_EQUAL( (std::string) p4, "2")
END_SECTION
// conversion operators
START_SECTION((operator std::string() const))
DataValue d((std::string) "test string");
std::string k = d;
TEST_EQUAL(k,"test string")
END_SECTION
START_SECTION((operator StringList() const))
StringList sl;
sl << "test string list";
DataValue d(sl);
StringList sl_op = d;
TEST_EQUAL(sl_op, d)
END_SECTION
START_SECTION((operator IntList() const))
IntList il;
il << 1<< 2;
DataValue d(il);
IntList il_op = d;
TEST_EQUAL(il_op,d);
TEST_EXCEPTION(Exception::ConversionError, (StringList)DataValue("abc,ab"))
END_SECTION
START_SECTION((operator DoubleList() const))
DoubleList dl;
dl<< 1.2 <<22.34455;
DataValue d(dl);
DoubleList dl_op = d;
TEST_EQUAL(dl_op,d);
END_SECTION
START_SECTION((operator long double() const))
DataValue d(5.4L);
long double k = d;
TEST_REAL_SIMILAR(k,5.4L)
END_SECTION
START_SECTION((operator double() const))
DataValue d(5.4);
double k = d;
TEST_REAL_SIMILAR(k,5.4)
END_SECTION
START_SECTION((operator float() const))
DataValue d(5.4f);
float k = d;
TEST_REAL_SIMILAR(k,5.4f)
END_SECTION
START_SECTION((operator int() const ))
DataValue d((Int) -55);
int k = d;
TEST_EQUAL(k,-55)
TEST_EXCEPTION(Exception::ConversionError, (int)DataValue(55.4))
END_SECTION
START_SECTION((operator unsigned int() const ))
DataValue d((Int) 55);
unsigned int k = d;
TEST_EQUAL(k,55)
TEST_EXCEPTION(Exception::ConversionError, (unsigned int)DataValue(-55))
TEST_EXCEPTION(Exception::ConversionError, (unsigned int)DataValue(55.4))
END_SECTION
START_SECTION((operator short int() const))
DataValue d((short int) -55);
short int k = d;
TEST_EQUAL(k,-55)
TEST_EXCEPTION(Exception::ConversionError, (short int)DataValue(55.4))
END_SECTION
START_SECTION((operator unsigned short int() const))
DataValue d((short int) 55);
unsigned short int k = d;
TEST_EQUAL(k,55)
TEST_EXCEPTION(Exception::ConversionError, (unsigned short int)DataValue(-55))
TEST_EXCEPTION(Exception::ConversionError, (unsigned short int)DataValue(55.4))
END_SECTION
START_SECTION((operator long int() const))
DataValue d((long int) -55);
long int k = d;
TEST_EQUAL(k,-55)
TEST_EXCEPTION(Exception::ConversionError, (long int)DataValue(55.4))
END_SECTION
START_SECTION((operator unsigned long int() const))
DataValue d((long int) 55);
unsigned long int k = d;
TEST_EQUAL(k,55)
TEST_EXCEPTION(Exception::ConversionError, (unsigned long int)DataValue(-55))
TEST_EXCEPTION(Exception::ConversionError, (unsigned long int)DataValue(55.4))
END_SECTION
START_SECTION((operator long long() const))
{
DataValue d((long long) 55);
long long k = d;
TEST_EQUAL(k,55)
}
{
DataValue d((long long) -1);
long long k = d;
TEST_EQUAL(k,-1)
}
{
DataValue d((SignedSize) -55);
SignedSize k = d;
TEST_EQUAL(k,-55)
}
TEST_EXCEPTION(Exception::ConversionError, (long int)DataValue(55.4))
END_SECTION
START_SECTION((operator unsigned long long() const))
{
DataValue d((unsigned long long) 55);
unsigned long long k = d;
TEST_EQUAL(k,55)
}
{
DataValue d((Size) 55);
Size k = d;
TEST_EQUAL(k,55)
}
TEST_EXCEPTION(Exception::ConversionError, (unsigned long int)DataValue(-55))
TEST_EXCEPTION(Exception::ConversionError, (unsigned long int)DataValue(55.4))
END_SECTION
START_SECTION(([EXTRA] friend bool operator==(const DataValue&, const DataValue&)))
DataValue a(5.0);
DataValue b(5.0);
TEST_EQUAL(a==b,true);
a = DataValue((DoubleReal)15.13);
b = DataValue((DoubleReal)15.13);
TEST_EQUAL(a==b,true);
a = DataValue((Real)15.13);
b = DataValue((Real)(17-1.87));
TEST_EQUAL(a==b,true);
a = DataValue((Int)5);
b = DataValue((Int)5);
TEST_EQUAL(a==b,true);
a = DataValue((UInt)5000);
b = DataValue((UInt)5000);
TEST_EQUAL(a==b,true);
a = DataValue("hello");
b = DataValue(std::string("hello"));
TEST_EQUAL(a==b,true);
a = DataValue((Real)15.13);
b = DataValue((Real)(15.13001));
TEST_EQUAL(a==b,false);
END_SECTION
START_SECTION(([EXTRA] friend bool operator!=(const DataValue&, const DataValue&)))
DataValue a(5.0);
DataValue b(5.1);
TEST_EQUAL(a!=b,true);
a = DataValue((DoubleReal)15.13001);
b = DataValue((DoubleReal)15.13);
TEST_EQUAL(a!=b,true);
END_SECTION
START_SECTION((const char* toChar() const))
DataValue a;
TEST_EQUAL(a.toChar() == NULL, true)
a = DataValue("hello");
TEST_STRING_EQUAL(a.toChar(),"hello")
a = DataValue(5);
TEST_EXCEPTION(Exception::ConversionError, a.toChar() )
END_SECTION
START_SECTION((String toString() const))
DataValue a;
TEST_EQUAL(a.toString(), "")
a = DataValue("hello");
TEST_EQUAL(a.toString(),"hello")
a = DataValue(5);
TEST_EQUAL(a.toString(), "5")
a = DataValue(47.11);
TEST_EQUAL(a.toString(), "47.11")
a = DataValue(-23456.78);
TEST_EQUAL(a.toString(), "-23456.78")
a = DataValue(StringList::create("test string,string2,last string"));
TEST_EQUAL(a.toString(), "[test string, string2, last string]")
a = DataValue(IntList::create("1,2,3,4,5"));
TEST_EQUAL(a.toString(),"[1, 2, 3, 4, 5]")
a= DataValue(DoubleList::create("1.2,23.3333"));
TEST_EQUAL(a.toString(),"[1.2, 23.3333]")
END_SECTION
START_SECTION((bool toBool() const))
//valid cases
DataValue a("true");
TEST_EQUAL(a.toBool(),true)
a = DataValue("false");
TEST_EQUAL(a.toBool(),false)
//invalid cases
a = DataValue();
TEST_EXCEPTION(Exception::ConversionError, a.toBool() )
a = DataValue("bla");
TEST_EXCEPTION(Exception::ConversionError, a.toBool() )
a = DataValue(12);
TEST_EXCEPTION(Exception::ConversionError, a.toBool() )
a = DataValue(34.45);
TEST_EXCEPTION(Exception::ConversionError, a.toBool() )
END_SECTION
START_SECTION((QString toQString() const))
DataValue a;
TEST_EQUAL(a.toQString().toStdString(), "")
a = DataValue("hello");
TEST_EQUAL(a.toQString().toStdString(),"hello")
a = DataValue(5);
TEST_EQUAL(a.toQString().toStdString(), "5")
a = DataValue(47.11);
TEST_EQUAL(a.toQString().toStdString(), "47.110000")
a = DataValue(-23456.78);
TEST_EQUAL(a.toQString().toStdString(), "-23456.780000")
a = DataValue(StringList::create("test string,string2,last string"));
TEST_EQUAL(a.toQString().toStdString(), "[test string, string2, last string]")
a =DataValue(IntList::create("1,2,3"));
TEST_EQUAL(a.toQString().toStdString(), "[1, 2, 3]")
a = DataValue(DoubleList::create("1.22,43.23232"));
TEST_EQUAL(a.toQString().toStdString(),"[1.22, 43.23232]")
END_SECTION
START_SECTION(([EXTRA] friend std::ostream& operator<<(std::ostream&, const DataValue&)))
DataValue a((Int)5), b((UInt)100), c((DoubleReal)1.111), d((DoubleReal)1.1), e("hello "), f(std::string("world")), g;
std::ostringstream os;
os << a << b << c << d << e << f << g;
TEST_EQUAL(os.str(),"51001.1111.1hello world")
END_SECTION
START_SECTION((DataType valueType() const))
DataValue a;
TEST_EQUAL(a.valueType(), DataValue::EMPTY_VALUE);
DataValue a1(1.45);
TEST_EQUAL(a1.valueType(), DataValue::DOUBLE_VALUE);
DataValue a2(1.34f);
TEST_EQUAL(a2.valueType(), DataValue::DOUBLE_VALUE);
DataValue a3(123);
TEST_EQUAL(a3.valueType(), DataValue::INT_VALUE);
DataValue a4("bla");
TEST_EQUAL(a4.valueType(), DataValue::STRING_VALUE);
DataValue a5(StringList::create("test string,string2,last string"));
TEST_EQUAL(a5.valueType(), DataValue::STRING_LIST)
DataValue a6(UInt(2));
TEST_EQUAL(a6.valueType(), DataValue::INT_VALUE);
DataValue a7(IntList::create("1,2,3"));
TEST_EQUAL(a7.valueType(),DataValue::INT_LIST)
DataValue a8(DoubleList::create("1.2,32.4567"));
TEST_EQUAL(a8.valueType(),DataValue::DOUBLE_LIST);
END_SECTION
START_SECTION((bool hasUnit() const))
{
DataValue a;
TEST_EQUAL(a.hasUnit(), false)
DataValue a1("bla");
TEST_EQUAL(a1.hasUnit(), false)
DataValue a2(1.45);
TEST_EQUAL(a2.hasUnit(), false)
a2.setUnit("millimeters");
TEST_EQUAL(a2.hasUnit(), true)
}
END_SECTION
START_SECTION((const String& getUnit() const))
{
DataValue a;
TEST_EQUAL(a.getUnit(), "")
DataValue a1(2.2);
TEST_EQUAL(a1.getUnit(), "")
a1.setUnit("ppm");
TEST_EQUAL(a1.getUnit(), "ppm")
}
END_SECTION
START_SECTION((void setUnit(const String& unit)))
{
DataValue a1(2.2);
TEST_EQUAL(a1.getUnit(), "")
a1.setUnit("ppm");
TEST_EQUAL(a1.getUnit(), "ppm")
a1.setUnit("kg");
TEST_EQUAL(a1.getUnit(), "kg")
}
END_SECTION
START_SECTION((DataValue& operator=(const char*)))
{
const char * v = "value";
DataValue a("v");
a = v;
TEST_EQUAL((String)a, "value")
}
END_SECTION
START_SECTION((DataValue& operator=(const std::string&)))
{
std::string v = "value";
DataValue a("v");
a = v;
TEST_EQUAL((String)a, "value")
}
END_SECTION
START_SECTION((DataValue& operator=(const String&)))
{
String v = "value";
DataValue a("v");
a = v;
TEST_EQUAL((String)a, "value")
}
END_SECTION
START_SECTION((DataValue& operator=(const QString&)))
{
QString v = "value";
DataValue a("v");
a = v;
TEST_EQUAL((String)a, "value")
}
END_SECTION
START_SECTION((DataValue& operator=(const StringList&)))
{
StringList v = StringList::create("value,value2");
DataValue a("v");
a = v;
TEST_EQUAL(((StringList)a).size(), 2)
ABORT_IF(((StringList)a).size() != 2)
TEST_EQUAL(((StringList)a)[0], "value")
TEST_EQUAL(((StringList)a)[1], "value2")
}
END_SECTION
START_SECTION((DataValue& operator=(const IntList&)))
{
IntList v = IntList::create("2,-3");
DataValue a("v");
a = v;
TEST_EQUAL(((IntList)a).size(), 2)
ABORT_IF(((IntList)a).size() != 2)
TEST_EQUAL(((IntList)a)[0], 2)
TEST_EQUAL(((IntList)a)[1], -3)
}
END_SECTION
START_SECTION((DataValue& operator=(const DoubleList&)))
{
DoubleList v = DoubleList::create("2.14,-3.45");
DataValue a("v");
a = v;
TEST_EQUAL(((DoubleList)a).size(), 2)
ABORT_IF(((DoubleList)a).size() != 2)
TEST_EQUAL(((DoubleList)a)[0], 2.14)
TEST_EQUAL(((DoubleList)a)[1], -3.45)
}
END_SECTION
START_SECTION((DataValue& operator=(const long double)))
{
const long double v = 2.44;
DataValue a("v");
a = v;
TEST_EQUAL((long double)a, 2.44)
}
END_SECTION
START_SECTION((DataValue& operator=(const double)))
{
const double v = 2.44;
DataValue a("v");
a = v;
TEST_EQUAL((double)a, 2.44)
}
END_SECTION
START_SECTION((DataValue& operator=(const float)))
{
const float v = 2.44f;
DataValue a("v");
a = v;
TEST_EQUAL((float)a, 2.44f)
}
END_SECTION
START_SECTION((DataValue& operator=(const short int)))
{
const short int v = 2;
DataValue a("v");
a = v;
TEST_EQUAL((short int)a, 2)
}
END_SECTION
START_SECTION((DataValue& operator=(const unsigned short int)))
{
const unsigned short int v = 2;
DataValue a("v");
a = v;
TEST_EQUAL((unsigned short int)a, 2)
}
END_SECTION
START_SECTION((DataValue& operator=(const int)))
{
const int v = 2;
DataValue a("v");
a = v;
TEST_EQUAL((int)a, 2)
}
END_SECTION
START_SECTION((DataValue& operator=(const unsigned)))
{
const unsigned v = 2;
DataValue a("v");
a = v;
TEST_EQUAL((unsigned)a, 2)
}
END_SECTION
START_SECTION((DataValue& operator=(const long int)))
{
const long int v = 2;
DataValue a("v");
a = v;
TEST_EQUAL((long int)a, 2)
}
END_SECTION
START_SECTION((DataValue& operator=(const unsigned long)))
{
const unsigned long v = 2;
DataValue a("v");
a = v;
TEST_EQUAL((unsigned long)a, 2)
}
END_SECTION
START_SECTION((DataValue& operator=(const long long)))
{
const long long v = 2;
DataValue a("v");
a = v;
TEST_EQUAL((long long)a, 2)
}
END_SECTION
START_SECTION((DataValue& operator=(const unsigned long long)))
{
const unsigned long long v = 2;
DataValue a("v");
a = v;
TEST_EQUAL((unsigned long long)a, 2)
}
END_SECTION
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
END_TEST
#ifdef __clang__
#pragma clang diagnostic pop
#endif
|