MCPcopy Create free account
hub / github.com/FastLED/FastLED / FL_TEST_FILE

Function FL_TEST_FILE

tests/fl/stl/cstdlib.cpp:4–254  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2#include "test.h"
3
4FL_TEST_FILE(FL_FILEPATH) {
5
6// Helper comparison function for integers
7static int compare_ints(const void* a, const void* b) {
8 int arg1 = *static_cast<const int*>(a);
9 int arg2 = *static_cast<const int*>(b);
10
11 if (arg1 < arg2) return -1;
12 if (arg1 > arg2) return 1;
13 return 0;
14}
15
16// Helper comparison function for integers in reverse order
17static int compare_ints_reverse(const void* a, const void* b) {
18 int arg1 = *static_cast<const int*>(a);
19 int arg2 = *static_cast<const int*>(b);
20
21 if (arg1 > arg2) return -1;
22 if (arg1 < arg2) return 1;
23 return 0;
24}
25
26// Helper comparison function for doubles
27static int compare_doubles(const void* a, const void* b) {
28 double arg1 = *static_cast<const double*>(a);
29 double arg2 = *static_cast<const double*>(b);
30
31 if (arg1 < arg2) return -1;
32 if (arg1 > arg2) return 1;
33 return 0;
34}
35
36// Helper struct for testing larger elements
37struct Point {
38 int x;
39 int y;
40
41 bool operator==(const Point& other) const {
42 return x == other.x && y == other.y;
43 }
44};
45
46// Comparison function for Points (sort by x, then y)
47static int compare_points(const void* a, const void* b) {
48 const Point* p1 = static_cast<const Point*>(a);
49 const Point* p2 = static_cast<const Point*>(b);
50
51 if (p1->x < p2->x) return -1;
52 if (p1->x > p2->x) return 1;
53 if (p1->y < p2->y) return -1;
54 if (p1->y > p2->y) return 1;
55 return 0;
56}
57
58FL_TEST_CASE("fl::qsort - basic functionality") {
59 FL_SUBCASE("sort empty array") {
60 int arr[1];
61 fl::qsort(arr, 0, sizeof(int), compare_ints);

Callers

nothing calls this directly

Calls 1

qsortFunction · 0.85

Tested by

no test coverage detected