tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

memutil_test.cc (1381B)


      1 // Copyright 2017 The Abseil Authors.
      2 //
      3 // Licensed under the Apache License, Version 2.0 (the "License");
      4 // you may not use this file except in compliance with the License.
      5 // You may obtain a copy of the License at
      6 //
      7 //      https://www.apache.org/licenses/LICENSE-2.0
      8 //
      9 // Unless required by applicable law or agreed to in writing, software
     10 // distributed under the License is distributed on an "AS IS" BASIS,
     11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 // See the License for the specific language governing permissions and
     13 // limitations under the License.
     14 
     15 // Unit test for memutil.cc
     16 
     17 #include "absl/strings/internal/memutil.h"
     18 
     19 #include <cstdlib>
     20 
     21 #include "gtest/gtest.h"
     22 
     23 namespace {
     24 
     25 TEST(MemUtil, memcasecmp) {
     26  // check memutil functions
     27  const char a[] = "hello there";
     28 
     29  EXPECT_EQ(absl::strings_internal::memcasecmp(a, "heLLO there",
     30                                               sizeof("hello there") - 1),
     31            0);
     32  EXPECT_EQ(absl::strings_internal::memcasecmp(a, "heLLO therf",
     33                                               sizeof("hello there") - 1),
     34            -1);
     35  EXPECT_EQ(absl::strings_internal::memcasecmp(a, "heLLO therf",
     36                                               sizeof("hello there") - 2),
     37            0);
     38  EXPECT_EQ(absl::strings_internal::memcasecmp(a, "whatever", 0), 0);
     39 }
     40 
     41 }  // namespace