source: tests/vector/vec2_int.cfa @ 5b24ee2

arm-ehjacob/cs343-translationnew-ast-unique-expr
Last change on this file since 5b24ee2 was 2444324, checked in by Dmitry Kobets <dkobets@…>, 2 years ago

Add tests for vec2 int

  • Property mode set to 100644
File size: 1.6 KB
Line 
1#include "../../libcfa/src/vec/vec2.hfa"
2#include <fstream.hfa>
3#include <limits.hfa>
4
5int main(void) {
6    vec2(int) v1 = {1,2};
7    sout | "ctor(x,y):" | v1;
8
9    vec2(int) v2 = v1;
10    sout | "copy ctor:" | v2;
11
12    v2 = (vec2(int)){3, 4};
13    sout | "assignment:" | v2;
14
15    v2 = v1;
16    sout | "move assignment:" | v2;
17
18    vec2(int) v3 = 0;
19    sout | "zero-init:" | v3;
20
21    v1 = 0;
22    sout | "zero-assign:" | v1;
23
24    vec2(int) v4 = {123};
25    sout | "fill-ctor:" | v4;
26
27    v1 = (vec2(int)){1, 3};
28    sout | "?-?:" | (v1 - (vec2(int)){1003, -14});
29
30    v1 -= (vec2(int)){1003, -14};
31    sout | "?-=?:" | v1;
32
33    v1 = -v1;
34    sout | "-?:" | v1;
35
36    v1 = (vec2(int)){1, 3};
37    sout | "?+?:" | (v1 + (vec2(int)){1003, -14});
38
39    v1 += (vec2(int)){1003, -14};
40    sout | "?+=?:" | v1;
41
42    v1 = (vec2(int)){15, 275};
43    sout | "v*s:" | v1 * 3;
44
45    sout | "s*v:" | 3 * v1;
46
47    v1 *= 3;
48    sout | "?*=?:" | v1;
49
50    v1 = (vec2(int)){21, -10};
51    sout | "?/?:" | (v1 / 3);
52
53    v1 /= 3;
54    sout | "?/=?:" | v1;
55
56    v1 = (vec2(int)){2, 3};
57    v2 = (vec2(int)){-3, 2};
58    sout | "dot_1:" | dot(v1, v2);
59
60    v2 = (vec2(int)){13, 2};
61    sout | "dot_2:" | dot(v1, v2);
62
63    v1 = (vec2(int)){4, 3};
64    sout | "length_squared:" | length_squared(v1);
65
66    vec2(int) geometric_normal = {5,6};
67    vec2(int) perturbed_normal = {4,5};
68    vec2(int) eyeline = {-1,0};
69    sout | "faceforward_nochange:" | faceforward(perturbed_normal, eyeline, geometric_normal);
70
71    eyeline = (vec2(int)){1,0};
72    sout | "faceforward_flip:" | faceforward(perturbed_normal, eyeline, geometric_normal);
73}
Note: See TracBrowser for help on using the repository browser.