changeset 613:1c9d99ac4b68

Misc: remove clamp, there is alternative in boost
author David Demelier <markand@malikania.fr>
date Mon, 21 Aug 2017 11:09:58 +0200
parents 18ec7f4fc3de
children 687b42509012
files misc/clamp.hpp misc/test-all.cpp misc/test-clamp.cpp
diffstat 3 files changed, 0 insertions(+), 83 deletions(-) [+]
line wrap: on
line diff
--- a/misc/clamp.hpp	Mon Aug 21 11:08:49 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-/*
- * clamp.hpp -- clamp a value
- *
- * Copyright (c) 2013-2016 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-/**
- * \file clamp.hpp
- * \brief Clamp function
- */
-
-#include <algorithm>
-
-/**
- * Clamp the value between low and high.
- *
- * \param value the value
- * \param low the minimum value
- * \param high the maximum value
- * \return the value between minimum and maximum
- */
-template <typename T>
-constexpr T clamp(T value, T low, T high) noexcept
-{
-    return (value < high) ? std::max(value, low) : std::min(value, high);
-}
\ No newline at end of file
--- a/misc/test-all.cpp	Mon Aug 21 11:08:49 2017 +0200
+++ b/misc/test-all.cpp	Mon Aug 21 11:09:58 2017 +0200
@@ -18,7 +18,6 @@
 
 #include <gtest/gtest.h>
 
-#include "test-clamp.cpp"
 #include "test-join.cpp"
 #include "test-strip.cpp"
 
--- a/misc/test-clamp.cpp	Mon Aug 21 11:08:49 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * test-clamp.cpp -- test clamp function
- *
- * Copyright (c) 2013-2016 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include "clamp.hpp"
-
-TEST(Clamp, normal)
-{
-    ASSERT_EQ(5, clamp(5, 0, 10));
-}
-
-TEST(Clamp, minimum)
-{
-    ASSERT_EQ(0, clamp(0, 0, 10));
-}
-
-TEST(Clamp, maximum)
-{
-    ASSERT_EQ(10, clamp(10, 0, 10));
-}
-
-TEST(Clamp, less)
-{
-    ASSERT_EQ(0, clamp(-10, 0, 10));
-}
-
-TEST(Clamp, higher)
-{
-    ASSERT_EQ(10, clamp(20, 0, 10));
-}