summaryrefslogtreecommitdiff
path: root/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/boolean_operators.cpp
blob: 3e4577a5efdd4e9285c2bec00f6e51cfb0edf787 (plain)
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
#include <snowhouse/snowhouse.h>
using namespace snowhouse;
#include "tests.h"

void BooleanOperators()
{
  std::cout << "================================================" << std::endl;
  std::cout << "   Boolean operators" << std::endl;
  std::cout << "================================================" << std::endl;

  std::cout << "ShouldHandleIsFalseOperator" << std::endl;
  {
    Assert::That(false, IsFalse());
  }

  std::cout << "ShouldHandleWhenIsFalseFails" << std::endl;
  {
    AssertTestFails(Assert::That(true, IsFalse()), "Expected: false");
  }

  std::cout << "ShouldHandleIsTrueOperator" << std::endl;
  {
    Assert::That(true, IsTrue());
  }

  std::cout << "ShouldHandleWhenIsTrueFails" << std::endl;
  {
    AssertTestFails(Assert::That(false, IsTrue()), "Expected: true");
  }

  std::cout << "ShouldHandleFluentIsTrue" << std::endl;
  {
    Assert::That(true, Is().True());
    AssertTestFails(Assert::That(false, Is().True()), "Expected: true");
  }

  std::cout << "ShouldHandleFluentIsFalse" << std::endl;
  {
    Assert::That(false, Is().False());
    AssertTestFails(Assert::That(true, Is().False()), "Expected: false");
  }

  std::cout << "ShouldTreatAssertWithoutConstraintAsBooleanConstrains" << std::endl;
  {
    Assert::That(true);
  }
}