sat_counter.test.cc (13962:9c1c64414fb7) sat_counter.test.cc (14210:8f7626532f4d)
1/*
2 * Copyright (c) 2019 Inria
3 * All rights reserved
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 83 unchanged lines hidden (view full) ---

92 for (double value = 0.0; value <= max_value; value++, counter++) {
93 const double saturation = value / max_value;
94 ASSERT_DOUBLE_EQ(counter.calcSaturation(), saturation);
95 }
96 ASSERT_TRUE(counter.isSaturated());
97}
98
99/**
1/*
2 * Copyright (c) 2019 Inria
3 * All rights reserved
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 83 unchanged lines hidden (view full) ---

92 for (double value = 0.0; value <= max_value; value++, counter++) {
93 const double saturation = value / max_value;
94 ASSERT_DOUBLE_EQ(counter.calcSaturation(), saturation);
95 }
96 ASSERT_TRUE(counter.isSaturated());
97}
98
99/**
100 * Test abrupt saturation.
101 */
102TEST(SatCounterTest, Saturate)
103{
104 const unsigned bits = 3;
105 const unsigned max_value = (1 << bits) - 1;
106 SatCounter counter(bits);
107 counter++;
108 ASSERT_FALSE(counter.isSaturated());
109
110 // Make sure the value added is what was missing to saturate
111 const unsigned diff = counter.saturate();
112 ASSERT_EQ(diff, max_value - 1);
113 ASSERT_TRUE(counter.isSaturated());
114}
115
116/**
100 * Test back and forth against an int.
101 */
102TEST(SatCounterTest, IntComparison)
103{
104 const unsigned bits = 3;
105 SatCounter counter(bits);
106 int value = 0;
107

--- 197 unchanged lines hidden ---
117 * Test back and forth against an int.
118 */
119TEST(SatCounterTest, IntComparison)
120{
121 const unsigned bits = 3;
122 SatCounter counter(bits);
123 int value = 0;
124

--- 197 unchanged lines hidden ---