Skip to content

Add unit tests for BDVCountryNameAndCode methods - #7

Open
devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1779972254-add-unit-tests
Open

Add unit tests for BDVCountryNameAndCode methods#7
devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1779972254-add-unit-tests

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Summary

Adds 53 unit tests covering all public methods, with primary focus on the new getCountrySuffixForPrefix: method. Tests are built and run via GNUstep on Linux using a simple make test command.

Changes

Test file (BDVCountryNameAndCodeTests.m):

  • getCountrySuffixForPrefix: — 6 test groups: unique dial codes, shared dial codes (e.g. +44 → GB/GG/IM/JE), string dial codes (e.g. "+1 684"), no-match, nil input, multiple shared codes (+61, +1, +47)
  • prefixForCountryCode: — known codes, case-insensitivity, non-existent code
  • countryNameAtIndex: — first/second entry, out-of-bounds
  • allCountryNames / allPrefixDialingCodes — count validation, spot checks
  • initWithPlistPath: — invalid path, nil path edge cases

Source changes (backwards-compatible):

  • Added initWithPlistPath: designated initializer for testability
  • Added helper accessors: prefixForCountryCode:, countryNameAtIndex:, allCountryNames, allPrefixDialingCodes
  • Changed getCountrySuffixForPrefix: parameter type from NSString * to id (plist stores dial codes as both NSNumber and NSString)
  • Guarded UIImage usage with __has_include(<UIKit/UIKit.h>) for cross-platform compilation
  • Moved ivars from @implementation block to @interface for GNU runtime compatibility
  • Extracted loadPlistFromPath: to share init logic between init and initWithPlistPath:

Build infrastructure:

  • Makefilemake test builds and runs the test suite
  • .gitignore — excludes build artifacts

Review & Testing Checklist for Human

  • Verify the new initWithPlistPath: initializer doesn't break existing init behavior when used from NSBundle (Xcode/iOS)
  • Confirm getCountrySuffixForPrefix: type change from NSString * to id is compatible with existing callers
  • Run make test locally to verify all 53 tests pass

Notes

All 53 tests pass on Ubuntu/GNUstep. The UIImage-dependent countryFlagForCurrentLocale method is excluded from testing on Linux (guarded by __has_include).

Link to Devin session: https://app.devin.ai/sessions/eff22b773a6d4323ba77f2886839fde8
Requested by: @basdvries

- Add 53 unit tests covering all public methods, with special focus on
  getCountrySuffixForPrefix (unique codes, shared codes, string dial codes,
  no-match, nil input)
- Add initWithPlistPath: initializer for testability
- Add helper methods: prefixForCountryCode:, countryNameAtIndex:,
  allCountryNames, allPrefixDialingCodes
- Guard UIImage usage with __has_include for cross-platform compilation
- Move ivars to header for GNU runtime compatibility
- Change getCountrySuffixForPrefix: param type from NSString* to id
  to correctly handle NSNumber dial codes from the plist
- Add Makefile for building/running tests with GNUstep on Linux
- Add .gitignore for build artifacts

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant