-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhance currency module in calculator plugin with exchange rate
- Loading branch information
1 parent
b68951c
commit 3b6fd75
Showing
5 changed files
with
228 additions
and
31 deletions.
There are no files selected for viewing
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
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
41 changes: 41 additions & 0 deletions
41
wox.core/plugin/system/calculator/modules/currency_test.go
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,41 @@ | ||
package modules | ||
|
||
import ( | ||
"testing" | ||
"wox/util" | ||
) | ||
|
||
func TestParseExchangeRateFromHKAB(t *testing.T) { | ||
ctx := util.NewTraceContext() | ||
err := util.GetLocation().Init() | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
m := &CurrencyModule{ | ||
rates: make(map[string]float64), | ||
} | ||
|
||
rates, err := m.parseExchangeRateFromHKAB(ctx) | ||
if err != nil { | ||
t.Errorf("TestParseExchangeRateFromHKAB failed: %v", err) | ||
return | ||
} | ||
|
||
// Check if we have rates | ||
if len(rates) < 2 { | ||
t.Errorf("Expected at least 2 rates, got %d", len(rates)) | ||
return | ||
} | ||
|
||
// Check USD rate | ||
if rates["USD"] != 1.0 { | ||
t.Errorf("Expected USD rate to be 1.0, got %f", rates["USD"]) | ||
} | ||
|
||
// Check CNY rate is in reasonable range (6-8) | ||
cnyRate := rates["CNY"] | ||
if cnyRate < 6.0 || cnyRate > 8.0 { | ||
t.Errorf("CNY rate %f is outside expected range [6.0, 8.0]", cnyRate) | ||
} | ||
} |