MCPcopy Create free account
hub / github.com/dcleblanc/SafeInt / StaticAssertTest

Function StaticAssertTest

Test/ConstExpr.cpp:522–558  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

520
521 template <typename T>
522 void StaticAssertTest()
523 {
524 static_assert(SafeInt<T>() == 0, "Default constr");
525 static_assert(SafeInt<T>((T)1), "T constr");
526 static_assert(SafeInt<T>(true), "bool constr");
527 // Floating point will not work due to presence of fpclassify
528 // static_assert(SafeInt<T>((float)1.0), "float constr");
529
530 StaticAssertTU<T, char>();
531 StaticAssertTU<T, signed char>();
532 StaticAssertTU<T, unsigned char>();
533 StaticAssertTU<T, signed short>();
534 StaticAssertTU<T, unsigned short>();
535 StaticAssertTU<T, signed int>();
536 StaticAssertTU<T, unsigned int>();
537 StaticAssertTU<T, signed long>();
538 StaticAssertTU<T, unsigned long>();
539 StaticAssertTU<T, signed long long>();
540 StaticAssertTU<T, unsigned long long>();
541
542 // Special case casting
543 static_assert((bool)(SafeInt<T>((T)1)), "Casting");
544 static_assert((wchar_t)(SafeInt<T>((T)1)), "Casting");
545 static_assert((float)(SafeInt<T>((T)1)), "Casting");
546 static_assert((double)(SafeInt<T>((T)1)), "Casting");
547 static_assert((long double)(SafeInt<T>((T)1)), "Casting");
548
549 // Unary operations
550 static_assert(!SafeInt<T>((T)0), "operator !");
551 static_assert(++SafeInt<T>((T)1), "operator ++");
552 static_assert(SafeInt<T>((T)1)++, "operator ++");
553 static_assert(--SafeInt<T>((T)2), "operator --");
554 static_assert(SafeInt<T>((T)2)--, "operator --");
555 static_assert(~SafeInt<T>((T)0), "operator ~");
556
557
558 }
559
560 template <typename T, typename U>
561 _CONSTEXPR14 T ConstMultiplyTU()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected