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

void ExpressionErrorHandling()
{
  std::cout << "================================================" << std::endl;
  std::cout << "   ExpressionErrorHandling" << std::endl;
  std::cout << "================================================" << std::endl;

  std::vector<int> collection;
  collection.push_back(1);
  collection.push_back(2);
  collection.push_back(3);
  
  std::cout << "AnInvalidAllOperationShouldBeReportedProperly" << std::endl;
  {
    AssertTestFails(Assert::That(collection, Has().All()), 
        "The expression after \"all\" operator does not yield any result");
  }
  
  std::cout << "AnInvalidAtLeastOperationShouldBeReportedProperly" << std::endl;
  {
    AssertTestFails(Assert::That(collection, Has().AtLeast(2)),
        "The expression after \"at least 2\" operator does not yield any result");
  }
  
}