about summary refs log tree commit diff homepage
path: root/test/CXX/symex/basic_c++/templates.cpp
blob: b248af423abfe4c7b6dd52d6ed009112e152ae77 (plain) (blame)
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
// REQUIRES: uclibc
// RUN: %clangxx %s -emit-llvm %O0opt -c -o %t.bc
// RUN: rm -rf %t.klee-out
// RUN: %klee --output-dir=%t.klee-out --exit-on-error --libc=uclibc %t.bc 2>&1

#include <cassert>

template <typename X, typename Y>
X multiply(X a, Y b) {
  return a * b;
}

template <int A>
int add(int summand) {
  return A + summand;
}

int main(int argc, char **args) {
  assert(add<7>(3) == 10);

  assert(multiply(7, 3) == 21);

  // Check if the float arguments are handled correctly
  assert(multiply(7.1f, 3) > 21);
  assert(multiply(3, 7.1f) == 21);

  return 0;
}