ApolloZhu / swift_qrcodejs

Compare c9deb8b ... +5 ... d25c50d

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.


@@ -29,7 +29,6 @@
Loading
29 29
    public let correctLevel: QRErrorCorrectLevel
30 30
    /// If the image codes has a border around its content.
31 31
    public let hasBorder: Bool
32 -
    private let typeNumber: Int
33 32
    private let model: QRCodeModel
34 33
35 34
    /// Construct a QRCode instance.
@@ -45,10 +44,10 @@
Loading
45 44
                 encoding: String.Encoding = .utf8,
46 45
                 errorCorrectLevel: QRErrorCorrectLevel = .H,
47 46
                 withBorder hasBorder: Bool = true) {
48 -
        guard let typeNumber = try? QRCodeType.typeNumber(of: text, errorCorrectLevel: errorCorrectLevel)
49 -
            , let model = QRCodeModel(text: text, encoding: encoding, typeNumber: typeNumber, errorCorrectLevel: errorCorrectLevel)
47 +
        
48 +
        guard let model = QRCodeModel(text: text, encoding: encoding, errorCorrectLevel: errorCorrectLevel)
50 49
            else { return nil }
51 -
        self.typeNumber = typeNumber
50 +
52 51
        self.model = model
53 52
        self.text = text
54 53
        self.correctLevel = errorCorrectLevel

@@ -68,8 +68,10 @@
Loading
68 68
69 69
extension QRCodeType {
70 70
    /// Get the type by string length
71 -
    static func typeNumber(of text: String, errorCorrectLevel: QRErrorCorrectLevel) throws -> Int {
72 -
        let textLength = text.utf8.count
71 +
    static func typeNumber(of text: String, encoding: String.Encoding = .utf8, errorCorrectLevel: QRErrorCorrectLevel) throws -> Int {
72 +
        
73 +
        let textLength = text.lengthOfBytes(using: encoding)
74 +
        
73 75
        let maxTypeNumber = QRCodeLimitLength.count
74 76
75 77
        var type = 1

@@ -30,14 +30,17 @@
Loading
30 30
    private let encodedText: QR8bitByte
31 31
    private var dataCache: [Int]
32 32
    
33 -
    init?(text: String, encoding: String.Encoding = .utf8, typeNumber: Int, errorCorrectLevel: QRErrorCorrectLevel) {
33 +
    init?(text: String, encoding: String.Encoding = .utf8, errorCorrectLevel: QRErrorCorrectLevel) {
34 34
        
35 35
        guard let encoded = QR8bitByte(text, encoding: encoding) else {
36 36
            return nil
37 37
        }
38 38
        
39 39
        self.encodedText = encoded
40 -
        self.typeNumber = typeNumber
40 +
        
41 +
        guard let newTypeNumber = try? QRCodeType.typeNumber(of: text, encoding: encoding, errorCorrectLevel: errorCorrectLevel) else { return nil }
42 +
        
43 +
        self.typeNumber = newTypeNumber
41 44
        self.errorCorrectLevel = errorCorrectLevel
42 45
        guard let dataCache = try? QRCodeModel.createData(
43 46
            typeNumber: typeNumber,

Everything is accounted for!

No changes detected that need to be reviewed.
What changes does Codecov check for?
Lines, not adjusted in diff, that have changed coverage data.
Files that introduced coverage data that had none before.
Files that have missing coverage data that once were tracked.
Files Coverage
Sources -0.01% 93.71%
Project Totals (14 files) 93.71%
Loading