// Copyright (C) 2019 The Android Open Source Project
//
// 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.

import {
  base64Decode,
  base64Encode,
  binaryDecode,
  binaryEncode,
  utf8Decode,
  utf8Encode,
} from './string_utils';

test('string_utils.stringToBase64', () => {
  const bytes = [...'Hello, world'].map(c => c.charCodeAt(0));
  const buffer = new Uint8Array(bytes);
  const b64Encoded = base64Encode(buffer);
  expect(b64Encoded).toEqual('SGVsbG8sIHdvcmxk');
  expect(base64Decode(b64Encoded)).toEqual(buffer);
});

test('string_utils.bufferToBase64', () => {
  const buffer = new Uint8Array([0xff, 0, 0, 0x81, 0x2a, 0xfe]);
  const b64Encoded = base64Encode(buffer);
  expect(b64Encoded).toEqual('/wAAgSr+');
  expect(base64Decode(b64Encoded)).toEqual(buffer);
});

test('string_utils.utf8EncodeAndDecode', () => {
  const testString = '¡HéllØ wörld!';
  const buffer = utf8Encode(testString);
  expect(buffer).toEqual(new Uint8Array([
    194,
    161,
    72,
    195,
    169,
    108,
    108,
    195,
    152,
    32,
    119,
    195,
    182,
    114,
    108,
    100,
    33
  ]));
  expect(utf8Decode(buffer)).toEqual(testString);
});

test('string_utils.binaryEncodeAndDecode', () => {
  const buf = new Uint8Array(256 + 4);
  for (let i = 0; i < 256; i++) {
    buf[i] = i;
  }
  buf.set([0xf0, 0x28, 0x8c, 0xbc], 256);
  const encodedStr = binaryEncode(buf);
  expect(encodedStr.length).toEqual(buf.length);
  const encodedThroughJson = JSON.parse(JSON.stringify(encodedStr));
  expect(binaryDecode(encodedStr)).toEqual(buf);
  expect(binaryDecode(encodedThroughJson)).toEqual(buf);
});
