not_fn_unittest.cc 702 B

1234567891011121314151617181920212223
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "base/functional/not_fn.h"
  5. #include <functional>
  6. #include "testing/gtest/include/gtest/gtest.h"
  7. namespace base {
  8. TEST(FunctionalTest, NotFn) {
  9. constexpr auto not_less = base::not_fn(std::less<>());
  10. using NotLessT = decltype(not_less);
  11. static_assert(static_cast<const NotLessT&>(not_less)(1, 1), "");
  12. static_assert(static_cast<NotLessT&>(not_less)(2, 1), "");
  13. static_assert(static_cast<const NotLessT&&>(not_less)(2, 2), "");
  14. static_assert(!static_cast<NotLessT&&>(not_less)(1, 2), "");
  15. }
  16. } // namespace base