/*
 * Copyright 2023 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "vector_tests/include/common_vector_test.h"

size_t strlength(const char *str) {
  size_t index = 0;
  while (str[index]) {
    index++;
  }
  return index;
}

bool strequal(const char *str1, const char *str2) {
  uint32_t index = 0;

  while (str1[index] && str2[index] && str1[index] == str2[index]) {
    index++;
  }

  return str1[index] == str2[index];
}

uint64_t random64(void) {
  static uint64_t state = 4;  // chosen by fair dice roll.
                              // guaranteed to be random.
  state *= 1234512345;
  state += 5432154321;
  return state;
}
