File: predicates.h

package info (click to toggle)
zfp 1.0.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,744 kB
  • sloc: cpp: 20,656; ansic: 18,871; pascal: 1,231; f90: 907; python: 255; makefile: 183; sh: 79; fortran: 70
file content (59 lines) | stat: -rw-r--r-- 1,681 bytes parent folder | download
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
#include "zfp/array1.hpp"

#include "gtest/gtest.h"

testing::AssertionResult ExpectEqPrintHexPred(const char* expected_expr, const char* actual_expr, uint64 expected, uint64 actual)
{
  if (actual == expected)
    return testing::AssertionSuccess();

  std::stringstream ss, msg;
  std::string expected_str, actual_str;

  ss.str("");
  ss << std::showbase << std::hex << expected;
  expected_str = ss.str();

  ss.str("");
  ss << std::showbase << std::hex << actual;
  actual_str = ss.str();

  msg << "\t  Expected: " << expected_expr;
  if (expected_str != expected_expr) {
    msg << "\n\t  Which is: " << std::showbase << std::hex << expected;
  }
  msg << "\nTo be equal to: " << actual_expr;
  if (actual_str != actual_expr) {
    msg << "\n\t  Which is: " << std::showbase << std::hex << actual;
  }

  return testing::AssertionFailure() << msg.str();
}

testing::AssertionResult ExpectNeqPrintHexPred(const char* expected_expr, const char* actual_expr, uint64 expected, uint64 actual)
{
  if (actual != expected)
    return testing::AssertionSuccess();

  std::stringstream ss, msg;
  std::string expected_str, actual_str;

  ss.str("");
  ss << std::showbase << std::hex << expected;
  expected_str = ss.str();

  ss.str("");
  ss << std::showbase << std::hex << actual;
  actual_str = ss.str();

  msg << "\t  Expected: " << expected_expr;
  if (expected_str != expected_expr) {
    msg << "\n\t  Which is: " << std::showbase << std::hex << expected;
  }
  msg << "\nNot to be equal to: " << actual_expr;
  if (actual_str != actual_expr) {
    msg << "\n\t  Which is: " << std::showbase << std::hex << actual;
  }

  return testing::AssertionFailure() << msg.str();
}