-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix BufferedStreamConsumer tests (#7773)
- Loading branch information
1 parent
c3c3e31
commit 62992bf
Showing
4 changed files
with
81 additions
and
37 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
airbyte-commons/src/main/java/io/airbyte/commons/bytes/ByteUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Copyright (c) 2021 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.commons.bytes; | ||
|
||
public class ByteUtils { | ||
|
||
public static long getSizeInBytes(String s) { | ||
return s.length() * 2; // by default UTF-8 encoding takes 2bytes per char | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
airbyte-commons/src/test/java/io/airbyte/commons/bytes/ByteUtilsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright (c) 2021 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.commons.bytes; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import org.apache.commons.lang3.RandomStringUtils; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class ByteUtilsTest { | ||
|
||
@Test | ||
public void testIt() { | ||
for (int i = 1; i < 1000; i++) { | ||
String s = RandomStringUtils.random(i); | ||
// for now the formula is just hardcoded to str length * 2 | ||
assertEquals(i * 2, ByteUtils.getSizeInBytes(s)); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters