adjust BROTLI_TEST effects

PiperOrigin-RevId: 792562401
diff --git a/c/common/platform.h b/c/common/platform.h
index cf48338..056811a 100644
--- a/c/common/platform.h
+++ b/c/common/platform.h
@@ -594,4 +594,9 @@
 #define BROTLI_CRASH() (void)abort()
 #endif
 
+/* Make BROTLI_TEST=0 act same as undefined. */
+#if defined(BROTLI_TEST) && ((1-BROTLI_TEST-1) == 0)
+#undef BROTLI_TEST
+#endif
+
 #endif  /* BROTLI_COMMON_PLATFORM_H_ */
diff --git a/c/dec/decode.c b/c/dec/decode.c
index c53cbb8..c266cdf 100644
--- a/c/dec/decode.c
+++ b/c/dec/decode.c
@@ -2937,16 +2937,15 @@
 
 /* Escalate internal functions visibility; for testing purposes only. */
 #if defined(BROTLI_TEST)
-BROTLI_BOOL SafeReadSymbolForTest(
+BROTLI_BOOL BrotliSafeReadSymbolForTest(
     const HuffmanCode*, BrotliBitReader*, brotli_reg_t*);
-BROTLI_BOOL SafeReadSymbolForTest(
+BROTLI_BOOL BrotliSafeReadSymbolForTest(
     const HuffmanCode* table, BrotliBitReader* br, brotli_reg_t* result) {
   return SafeReadSymbol(table, br, result);
 }
-
-void InverseMoveToFrontTransformForTest(
+void BrotliInverseMoveToFrontTransformForTest(
     uint8_t*, brotli_reg_t, BrotliDecoderState*);
-void InverseMoveToFrontTransformForTest(
+void BrotliInverseMoveToFrontTransformForTest(
     uint8_t* v, brotli_reg_t l, BrotliDecoderState* s) {
   InverseMoveToFrontTransform(v, l, s);
 }
diff --git a/c/enc/block_splitter.c b/c/enc/block_splitter.c
index 470fabb..13e924f 100644
--- a/c/enc/block_splitter.c
+++ b/c/enc/block_splitter.c
@@ -196,16 +196,15 @@
 }
 
 #if defined(BROTLI_TEST)
-size_t CountLiteralsForTest(const Command*, const size_t);
-size_t CountLiteralsForTest(const Command* cmds, const size_t num_commands) {
+size_t BrotliCountLiteralsForTest(const Command*, size_t);
+size_t BrotliCountLiteralsForTest(const Command* cmds, size_t num_commands) {
   return CountLiterals(cmds, num_commands);
 }
-
-void CopyLiteralsToByteArrayForTest(const Command*,
-    const size_t, const uint8_t*, const size_t, const size_t, uint8_t*);
-void CopyLiteralsToByteArrayForTest(const Command* cmds,
-    const size_t num_commands, const uint8_t* data, const size_t offset,
-    const size_t mask, uint8_t* literals) {
+void BrotliCopyLiteralsToByteArrayForTest(
+    const Command*, size_t, const uint8_t*, size_t, size_t, uint8_t*);
+void BrotliCopyLiteralsToByteArrayForTest(const Command* cmds,
+    size_t num_commands, const uint8_t* data, size_t offset, size_t mask,
+    uint8_t* literals) {
   CopyLiteralsToByteArray(cmds, num_commands, data, offset, mask, literals);
 }
 #endif
diff --git a/c/enc/brotli_bit_stream.c b/c/enc/brotli_bit_stream.c
index 779c843..ec0421a 100644
--- a/c/enc/brotli_bit_stream.c
+++ b/c/enc/brotli_bit_stream.c
@@ -1321,8 +1321,10 @@
 }
 
 #if defined(BROTLI_TEST)
-void GetBlockLengthPrefixCodeForTest(uint32_t len, size_t* code,
-                                     uint32_t* n_extra, uint32_t* extra) {
+void BrotliGetBlockLengthPrefixCodeForTest(uint32_t len, size_t* code,
+                                           uint32_t* n_extra, uint32_t* extra);
+void BrotliGetBlockLengthPrefixCodeForTest(uint32_t len, size_t* code,
+                                           uint32_t* n_extra, uint32_t* extra) {
   GetBlockLengthPrefixCode(len, code, n_extra, extra);
 }
 #endif
diff --git a/c/enc/brotli_bit_stream.h b/c/enc/brotli_bit_stream.h
index 9ca493d..7b72bdc 100644
--- a/c/enc/brotli_bit_stream.h
+++ b/c/enc/brotli_bit_stream.h
@@ -76,10 +76,6 @@
     size_t position, size_t mask, size_t len,
     size_t* BROTLI_RESTRICT storage_ix, uint8_t* BROTLI_RESTRICT storage);
 
-#if defined(BROTLI_TEST)
-void GetBlockLengthPrefixCodeForTest(uint32_t, size_t*, uint32_t*, uint32_t*);
-#endif
-
 #if defined(__cplusplus) || defined(c_plusplus)
 }  /* extern "C" */
 #endif
diff --git a/c/enc/encode.c b/c/enc/encode.c
index 5a7641d..0d76f8a 100644
--- a/c/enc/encode.c
+++ b/c/enc/encode.c
@@ -1994,8 +1994,8 @@
 }
 
 #if defined(BROTLI_TEST)
-size_t MakeUncompressedStreamForTest(const uint8_t*, size_t, uint8_t*);
-size_t MakeUncompressedStreamForTest(
+size_t BrotliMakeUncompressedStreamForTest(const uint8_t*, size_t, uint8_t*);
+size_t BrotliMakeUncompressedStreamForTest(
     const uint8_t* input, size_t input_size, uint8_t* output) {
   return MakeUncompressedStream(input, input_size, output);
 }
diff --git a/c/enc/encoder_dict.c b/c/enc/encoder_dict.c
index 26ffda8..bc4e0e6 100644
--- a/c/enc/encoder_dict.c
+++ b/c/enc/encoder_dict.c
@@ -632,8 +632,8 @@
 
 /* Escalate internal functions visibility; for testing purposes only. */
 #if defined(BROTLI_TEST)
-void InitEncoderDictionaryForTest(BrotliEncoderDictionary*);
-void InitEncoderDictionaryForTest(BrotliEncoderDictionary* d) {
+void BrotliInitEncoderDictionaryForTest(BrotliEncoderDictionary*);
+void BrotliInitEncoderDictionaryForTest(BrotliEncoderDictionary* d) {
   InitEncoderDictionary(d);
 }
 #endif
diff --git a/c/include/brotli/port.h b/c/include/brotli/port.h
index 0d50019..0c486d9 100644
--- a/c/include/brotli/port.h
+++ b/c/include/brotli/port.h
@@ -239,8 +239,6 @@
 #define BROTLI_PUBLIC
 #endif
 
-/* BROTLI_INTERNAL could be defined to override visibility, e.g. for tests. */
-#if !defined(BROTLI_INTERNAL)
 #if defined(_WIN32) || defined(__CYGWIN__)
 #define BROTLI_INTERNAL
 #elif BROTLI_GNUC_VERSION_CHECK(3, 3, 0) ||                         \
@@ -255,7 +253,6 @@
 #else
 #define BROTLI_INTERNAL
 #endif
-#endif
 
 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) &&   \
     !defined(__STDC_NO_VLA__) && !defined(__cplusplus) &&           \