| /* |
| * Copyright 2010-2026 JetBrains s.r.o. and Kotlin Programming Language contributors. |
| * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. |
| */ |
| |
| |
| package test.generated.alldistinct |
| |
| // |
| // NOTE: THIS FILE IS AUTO-GENERATED by the AllDistinctTestGenerator.kt |
| // See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib |
| // |
| |
| import kotlin.test.* |
| |
| class AllDistinctUByteArrayTest { |
| |
| @Test |
| fun allDistinct() { |
| assertTrue(ubyteArrayOf().allDistinct()) |
| assertTrue(ubyteArrayOf(1u).allDistinct()) |
| assertTrue(ubyteArrayOf(1u, 2u).allDistinct()) |
| assertFalse(ubyteArrayOf(1u, 1u).allDistinct()) |
| assertFalse(ubyteArrayOf(2u, 2u).allDistinct()) |
| assertFalse(ubyteArrayOf(1u, 2u, 1u).allDistinct()) |
| assertFalse(ubyteArrayOf(2u, 1u, 2u).allDistinct()) |
| } |
| |
| @Test |
| fun allDistinctBy() { |
| assertTrue(ubyteArrayOf().allDistinctBy { it.toUInt() % 2u }) |
| assertTrue(ubyteArrayOf(1u).allDistinctBy { it.toUInt() % 2u }) |
| assertTrue(ubyteArrayOf(1u).allDistinctBy { error("should not be called") }) |
| assertTrue(ubyteArrayOf(1u, 2u).allDistinctBy { it.toUInt() % 2u }) |
| assertFalse(ubyteArrayOf(1u, 3u, 5u).allDistinctBy { it.toUInt() % 2u }) |
| assertFalse(ubyteArrayOf(1u, 2u).allDistinctBy { 0 }) |
| assertFalse(ubyteArrayOf(1u, 2u).allDistinctBy { null }) |
| } |
| |
| @Test |
| fun allDistinctValueDomainBounds() { |
| assertTrue(UByteArray(256) { it.toUByte() }.allDistinct()) |
| assertFalse(UByteArray(256) { (it / 2).toUByte() }.allDistinct()) |
| assertFalse(UByteArray(257) { it.toUByte() }.allDistinct()) |
| } |
| } |