wangzhibo
2026-08-16 ae6f40460dcd56af6c5f60ba52c883854c3bac55
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package nodomain.freeyourgadget.gadgetbridge.util;
 
import static org.junit.Assert.*;
 
import org.junit.Test;
import org.robolectric.RuntimeEnvironment;
 
import java.util.HashMap;
import java.util.Map;
 
import nodomain.freeyourgadget.gadgetbridge.test.TestBase;
 
public class EmojiConverterTest extends TestBase {
    @Test
    public void testConvert() {
        final Map<String, String> snippets = new HashMap<String, String>() {{
            put(
                    "no emoji",
                    "no emoji"
            );
 
            put(
                    "Hello! \uD83D\uDE0A",
                    "Hello! :-)"
            );
 
            put(
                    "\uD83D\uDE1B hi",
                    ":-P hi"
            );
 
            put(
                    "\uD83D\uDC7B\uD83D\uDC80",
                    ":ghost::skull:"
            );
 
            put(
                    "also \uD83D\uDE36 with words \uD83D\uDCAA\uD83C\uDFFC in-between \uD83D\uDE09",
                    "also :no_mouth: with words :muscle: in-between ;-)"
            );
        }};
 
        for (final Map.Entry<String, String> e : snippets.entrySet()) {
            assertEquals(
                    e.getValue(),
                    EmojiConverter.convertUnicodeEmojiToAscii(
                            e.getKey(),
                            RuntimeEnvironment.getApplication()
                    )
            );
        }
    }
}