-
Notifications
You must be signed in to change notification settings - Fork 874
清理 CPU 名称 #3928
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
清理 CPU 名称 #3928
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c3846d4
清理 CPU 名称
Glavo f710b16
update
Glavo 0942069
update
Glavo 0c8f3c8
update
Glavo 7aa971c
update
Glavo 46d0ac6
update
Glavo d873a54
update
Glavo 6b7c883
update
Glavo 6de1d3f
update
Glavo 18d4517
update
Glavo f47eebe
update
Glavo 27a828c
update
Glavo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -17,12 +17,46 @@ | |||||
| */ | ||||||
| package org.jackhuang.hmcl.util.platform.hardware; | ||||||
|
|
||||||
| import org.jackhuang.hmcl.util.StringUtils; | ||||||
| import org.jetbrains.annotations.Nullable; | ||||||
|
|
||||||
| /** | ||||||
| * @author Glavo | ||||||
| */ | ||||||
| public final class CentralProcessor { | ||||||
|
|
||||||
| public static String cleanName(String name) { | ||||||
| if (name == null) | ||||||
| return null; | ||||||
|
Glavo marked this conversation as resolved.
|
||||||
| return null; | |
| return ""; |
Glavo marked this conversation as resolved.
Glavo marked this conversation as resolved.
This file contains hidden or 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 hidden or 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
50 changes: 50 additions & 0 deletions
50
HMCLCore/src/test/java/org/jackhuang/hmcl/util/StringUtilsTest.java
This file contains hidden or 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,50 @@ | ||
| /* | ||
| * Hello Minecraft! Launcher | ||
| * Copyright (C) 2025 huangyuhui <huanghongxun2008@126.com> and contributors | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| */ | ||
| package org.jackhuang.hmcl.util; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
|
||
| /** | ||
| * @author Glavo | ||
| */ | ||
| public final class StringUtilsTest { | ||
|
|
||
| @Test | ||
| public void testNormalizeWhitespaces() { | ||
| assertEquals("", StringUtils.normalizeWhitespaces("")); | ||
| assertEquals("", StringUtils.normalizeWhitespaces(" ")); | ||
| assertEquals("", StringUtils.normalizeWhitespaces(" \t")); | ||
| assertEquals("", StringUtils.normalizeWhitespaces(" \t ")); | ||
|
|
||
| assertEquals("abc", StringUtils.normalizeWhitespaces("abc")); | ||
| assertEquals("abc", StringUtils.normalizeWhitespaces(" abc")); | ||
| assertEquals("abc", StringUtils.normalizeWhitespaces("abc ")); | ||
| assertEquals("abc", StringUtils.normalizeWhitespaces(" abc ")); | ||
| assertEquals("abc", StringUtils.normalizeWhitespaces(" \tabc \t")); | ||
|
|
||
| assertEquals("a bc", StringUtils.normalizeWhitespaces("a bc")); | ||
| assertEquals("a bc", StringUtils.normalizeWhitespaces("a bc")); | ||
| assertEquals("a bc", StringUtils.normalizeWhitespaces("a \tbc")); | ||
| assertEquals("a bc", StringUtils.normalizeWhitespaces(" a \tbc ")); | ||
| assertEquals("a b c", StringUtils.normalizeWhitespaces(" a\tb c ")); | ||
| assertEquals("a b c", StringUtils.normalizeWhitespaces(" a \t b c ")); | ||
| assertEquals("a b c", StringUtils.normalizeWhitespaces(" a \t b c ")); | ||
| } | ||
| } |
68 changes: 68 additions & 0 deletions
68
HMCLCore/src/test/java/org/jackhuang/hmcl/util/platform/hardware/CentralProcessorTest.java
This file contains hidden or 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,68 @@ | ||
| /* | ||
| * Hello Minecraft! Launcher | ||
| * Copyright (C) 2025 huangyuhui <huanghongxun2008@126.com> and contributors | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| */ | ||
| package org.jackhuang.hmcl.util.platform.hardware; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import static org.jackhuang.hmcl.util.platform.hardware.CentralProcessor.cleanName; | ||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
|
||
| /** | ||
| * @author Glavo | ||
| */ | ||
| public final class CentralProcessorTest { | ||
|
|
||
| @Test | ||
| public void testCleanName() { | ||
| assertEquals("Intel Core i7-12700K", cleanName("12th Gen Intel(R) Core(TM) i7-12700K")); | ||
| assertEquals("Intel Core Ultra 9 285K", cleanName("Intel(R) Core(TM) Ultra 9 285K")); | ||
| assertEquals("Intel Xeon Platinum 8380", cleanName("Intel(R) Xeon(R) Platinum 8380 CPU @ 2.30GHz")); | ||
| assertEquals("Intel Xeon E5-2660 v2", cleanName("Intel(R) Xeon(R) CPU E5-2660 v2 @ 2.20GHz")); | ||
| assertEquals("Intel Xeon Phi 7250", cleanName("Intel(R) Xeon Phi(TM) CPU 7250 @ 1.40GHz")); | ||
| assertEquals("Intel Celeron N5105", cleanName("Intel(R) Celeron(R) N5105 @ 2.00GHz")); | ||
| assertEquals("Intel Pentium Silver J5005", cleanName("Intel(R) Pentium(R) Silver J5005 CPU @ 1.50GHz")); | ||
| assertEquals("Intel Atom E3940", cleanName("Intel(R) Atom(TM) Processor E3940 @ 1.60GHz")); | ||
| assertEquals("Intel Core i7 X 990", cleanName("Intel(R) Core(TM) i7 CPU X 990 @ 3.47GHz")); | ||
| assertEquals("Intel Core 2 Duo T7500", cleanName("Intel(R) Core(TM)2 Duo CPU T7500 @ 2.20GHz")); | ||
| assertEquals("Intel Core 2 Quad Q9500", cleanName("Intel(R) Core(TM)2 Quad CPU Q9500 @ 2.83GHz")); | ||
|
|
||
| assertEquals("AMD Ryzen 7 7840HS", cleanName("AMD Ryzen 7 7840HS w/ Radeon 780M Graphics")); | ||
| assertEquals("AMD Ryzen 7 6800U", cleanName("AMD Ryzen 7 6800U with Radeon Graphics")); | ||
| assertEquals("AMD Ryzen 7 5800X", cleanName("AMD Ryzen 7 5800X 8-Core Processor")); | ||
| assertEquals("AMD Ryzen 5 2400G", cleanName("AMD Ryzen 5 2400G with Radeon Vega Graphics")); | ||
| assertEquals("AMD EPYC 7713", cleanName("AMD EPYC 7713 64-Core Processor")); | ||
| assertEquals("AMD Ryzen Threadripper 3960X", cleanName("AMD Ryzen Threadripper 3960X 24-Core Processor")); | ||
| assertEquals("AMD Ryzen Threadripper PRO 5995WX", cleanName("AMD Ryzen Threadripper PRO 5995WX 64-Cores")); | ||
| assertEquals("AMD Ryzen Embedded V2748", cleanName("AMD Ryzen Embedded V2748 with Radeon Graphics")); | ||
| assertEquals("AMD A8-7410", cleanName("AMD A8-7410 APU with AMD Radeon R5 Graphics")); | ||
| assertEquals("AMD FX-8350", cleanName("AMD FX(tm)-8350 Eight-Core Processor")); | ||
| assertEquals("AMD Phenom II X6 1055T", cleanName("AMD Phenom(tm) II X6 1055T Processor")); | ||
| assertEquals("AMD Athlon 5350", cleanName("AMD Athlon(tm) 5350 APU with Radeon(tm) R3")); | ||
|
|
||
| assertEquals("Hygon C86 7285", cleanName("Hygon C86 7285 32-core Processor")); | ||
| assertEquals("Hygon C86 3250", cleanName("Hygon C86 3250 8-core Processor")); | ||
|
|
||
| assertEquals("ZHAOXIN KaiXian KX-6640MA", cleanName("ZHAOXIN KaiXian KX-6640MA@2.2+GHz")); | ||
| assertEquals("ZHAOXIN KaiXian KX-U6780A", cleanName("ZHAOXIN KaiXian KX-U6780A@2.7GHz")); | ||
| assertEquals("ZHAOXIN KaiSheng KH-40000/16", cleanName("ZHAOXIN KaiSheng KH-40000/16@2.2GHz")); | ||
| assertEquals("ZHAOXIN KaiSheng KH-37800D", cleanName("ZHAOXIN KaiSheng KH-37800D@2.7GHz")); | ||
|
|
||
| assertEquals("Loongson-3A3000", cleanName("Loongson-3A R3 (Loongson-3A3000) @ 1400MHz")); | ||
| assertEquals("Loongson-3B4000", cleanName("Loongson-3A R4 (Loongson-3B4000) @ 1800MHz")); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
cleanNamemethod lacks a JavaDoc explaining its normalization rules and null behavior. Consider adding a description of input/output expectations and examples.