Skip to content

Commit

Permalink
Add Test (#39)
Browse files Browse the repository at this point in the history
* Update LICENSE

* crop image

* Edit README

* remove unnecessary env

* change tests from XCTAssert to expect toBe

* Change to Korean
  • Loading branch information
sboh1214 committed Dec 20, 2020
1 parent f1657c8 commit bf2bd0b
Show file tree
Hide file tree
Showing 18 changed files with 321 additions and 238 deletions.
24 changes: 24 additions & 0 deletions .github/i18n/en/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Contributing

> This document might be outdated. Please make a Issue.
## Coding Style

This project uses [SwiftLint](https://github.com/realm/SwiftLint),
[markdownlint](https://github.com/markdownlint/markdownlint),
and [pre-commit](https://pre-commit.com/)
to enforce formatting and coding style.

```
brew install swiftlint
gem install mdl
brew install pre-commit
pre-commit install
```

SwiftLint also run on CI for every PR.

## Code Quality

[![Maintainability](https://api.codeclimate.com/v1/badges/b920b09bdee71fdc8208/maintainability)](https://codeclimate.com/github/sboh1214/Hwp-Swift/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/b920b09bdee71fdc8208/test_coverage)](https://codeclimate.com/github/sboh1214/Hwp-Swift/test_coverage)
32 changes: 32 additions & 0 deletions .github/i18n/en/SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Security Policy

> This document might be outdated. Please make a Issue.
## Known Issues

- < 0.4.1
HwpFile > docInfo > idMappings > faceNameKorean(Count/Array) 누락

```
Below is Template
```

## Supported Versions

Use this section to tell people about which versions of your project are
currently being supported with security updates.

| Version | Supported |
| ------- | ------------------ |
| 5.1.x | :white_check_mark: |
| 5.0.x | :x: |
| 4.0.x | :white_check_mark: |
| < 4.0 | :x: |

## Reporting a Vulnerability

Use this section to tell people how to report a vulnerability.

Tell them where to go, how often they can expect to get an update on a
reported vulnerability, what to expect if the vulnerability is accepted or
declined, etc.
13 changes: 12 additions & 1 deletion .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,15 @@ file_length:
warning: 500
error: 700

reporter: "xcode" # reporter type (xcode, json, csv, checkstyle, junit, html, emoji, sonarqube, markdown, github-actions-logging)
custom_rules:
no_xctassert:
name: "No XCTAssert"
regex: "(XCTAssert)"
match_kinds:
- comment
- identifier
message: "Use Nimble expect ~ to be ~ pattern"
severity: error

# reporter type (xcode, json, csv, checkstyle, junit, html, emoji, sonarqube, markdown, github-actions-logging)
reporter: "xcode"
12 changes: 6 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Contribute
# 기여

## Coding Style
## 코딩 스타일

This project uses [SwiftLint](https://github.com/realm/SwiftLint),
이 프로젝트는 코드 포맷과 스타일을 강제하기 위해 [SwiftLint](https://github.com/realm/SwiftLint),
[markdownlint](https://github.com/markdownlint/markdownlint),
and [pre-commit](https://pre-commit.com/)
to enforce formatting and coding style.
를 사용합니다.

```
brew install swiftlint
Expand All @@ -14,9 +14,9 @@ brew install pre-commit
pre-commit install
```

SwiftLint also run on CI for every PR.
SwiftLint는 또한 모든 PR에서 CI로 확인됩니다.

## Code Quality
## 코드 퀄리티

[![Maintainability](https://api.codeclimate.com/v1/badges/b920b09bdee71fdc8208/maintainability)](https://codeclimate.com/github/sboh1214/Hwp-Swift/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/b920b09bdee71fdc8208/test_coverage)](https://codeclimate.com/github/sboh1214/Hwp-Swift/test_coverage)
9 changes: 7 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/CoreOffice/OLEKit.git", .exact("0.2.0")),
.package(url: "https://github.com/tsolomko/SWCompression.git", .exact("4.5.7"))
.package(url: "https://github.com/tsolomko/SWCompression.git", .exact("4.5.7")),

.package(url: "https://github.com/Quick/Nimble", .exact("9.0.0"))
],
targets: [
.target(
Expand All @@ -21,7 +23,10 @@ let package = Package(
),
.testTarget(
name: "CoreHwpTests",
dependencies: ["CoreHwp"],
dependencies: [
"CoreHwp",
"Nimble"
],
resources: [
.copy("Blank/blank-mac2014vp.hwp"),
.copy("Blank/blank-win2018.hwp"),
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[English](https://github.com/sboh1214/Hwp-Swift/blob/main/.github/i18n/en/README.md)

> This software is developed using Hancom's HANGEUL DOCUMENT FILE FORMAT.
> 본 제품은 한글과컴퓨터의 글 문서 파일(.hwp) 공개 문서를 참고하여 개발하였습니다.
![Test](https://github.com/sboh1214/Hwp-Swift/workflows/Test/badge.svg)
![Coverage](https://github.com/sboh1214/Hwp-Swift/workflows/Coverage/badge.svg)
Expand All @@ -15,11 +15,11 @@

## 설치

### Swift Package Manager
### 스위프트 패키지 관리자

Xcode에서 ```File``` > ```Swift Packages``` > ```Add Package Dependency...``` 메뉴를 선택하세요.

또는 Dependency를 아래와 같이 수동으로 추가합니다.
또는 의존성을 아래와 같이 수동으로 추가합니다.

```swift
dependencies: [
Expand All @@ -33,7 +33,7 @@ dependencies: [

## 기여

Visit [CONTRIBUTING.md](https://github.com/sboh1214/Hwp-Swift/blob/main/CONTRIBUTING.md)
[CONTRIBUTING.md](https://github.com/sboh1214/Hwp-Swift/blob/main/CONTRIBUTING.md)를 방문하세요.

## 라이센스

Expand Down
16 changes: 8 additions & 8 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Security Policy
# 보안 정책

## Supported Versions
## 알려진 이슈

- < 0.4.1
HwpFile > docInfo > idMappings > faceNameKorean(Count/Array) 누락

## 지원 버전

Use this section to tell people about which versions of your project are
currently being supported with security updates.
Expand All @@ -10,12 +15,7 @@ currently being supported with security updates.
| < 0.9.0 | :x: |
| 0.9.x | :white_check_mark: |

## Known Issues

- < 0.4.1
HwpFile > docInfo > idMappings > faceNameKorean(Count/Array) 누락

## Reporting a Vulnerability
## 취약점 제보

Use this section to tell people how to report a vulnerability.

Expand Down
4 changes: 2 additions & 2 deletions Sources/CoreHwp/Models/Section/Ctrl Header/HwpColumn.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public struct HwpColumn {
/**단 너비가 동일하지 않으면, 단의 개수만큼 단의 폭*/
public var widthArray: [WORD]
/**속성의 bit 16-32*/
//public var property2: UInt16
// public var property2: UInt16
/**단 구분선 종류*/
public var dividerType: UInt8
/**단 구분선 굵기*/
Expand All @@ -32,7 +32,7 @@ extension HwpColumn: HwpFromData {
spacing = reader.read(HWPUNIT16.self)
let count = getBitValue(Int(property), 2, 9)
widthArray = (0..<count).map { _ in reader.read(WORD.self)}
//property2 = reader.read(UInt16.self)
// property2 = reader.read(UInt16.self)
dividerType = reader.read(UInt8.self)
dividerThickness = reader.read(UInt8.self)
dividerColor = HwpColor(reader.read(COLORREF.self))
Expand Down
12 changes: 4 additions & 8 deletions Tests/CoreHwpTests/Blank/BlankTests.swift
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
import CoreHwp
import XCTest
import Nimble

final class BlankTests: XCTestCase {

func testOpen() throws {
let hwp = try openHwp(#file, "blank-mac2014vp")
XCTAssertNotNil(hwp.fileHeader)
}

func testSignature() throws {
let hwp = try openHwp(#file, "blank-mac2014vp")
XCTAssertEqual(hwp.fileHeader.signature, "HWP Document File\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0")
expect(hwp.fileHeader.signature) == "HWP Document File\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
}

func testHwpVersion() throws {
let hwp = try openHwp(#file, "blank-mac2014vp")
XCTAssertEqual(hwp.fileHeader.version, HwpVersion(5, 1, 0, 1))
expect(hwp.fileHeader.version) == HwpVersion(5, 1, 0, 1)
}

func testEncryptVersion() throws {
let hwp = try openHwp(#file, "blank-mac2014vp")
XCTAssertEqual(hwp.fileHeader.encryptVersion, 4)
expect(hwp.fileHeader.encryptVersion) == 4
}
}
27 changes: 14 additions & 13 deletions Tests/CoreHwpTests/Blank/Create2014Tests.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import CoreHwp
import XCTest
import Nimble

/**
doc version : unknown
Expand All @@ -8,36 +8,37 @@ import XCTest
final class Create2014Tests: XCTestCase {

func testCreate() throws {
// XCTAssertEqual(expected, actual)
// expect(expected, actual)
}

func testfileHeader() throws {
let (official, this) = try createHwp(#file, "blank-mac2014vp")

XCTAssertEqual(official.fileHeader, this.fileHeader)
expect(this.fileHeader) == official.fileHeader
}

func testDocInfo() throws {
let (official, this) = try createHwp(#file, "blank-mac2014vp")

XCTAssertEqual(official.docInfo.documentProperties, this.docInfo.documentProperties)
XCTAssertEqual(official.docInfo.compatibleDocument, this.docInfo.compatibleDocument)
expect(official.docInfo.documentProperties) == this.docInfo.documentProperties
expect(official.docInfo.compatibleDocument) == this.docInfo.compatibleDocument

let officialMappings = official.docInfo.idMappings
let thisMappings = this.docInfo.idMappings
// XCTAssertEqual(expectedMappings.faceNameArray, actualMappings.faceNameArray)
XCTAssertEqual(officialMappings.borderFillArray, thisMappings.borderFillArray)
// XCTAssertEqual(officialMappings.charShapeArray, thisMappings.charShapeArray)
XCTAssertEqual(officialMappings.paraShapeArray, thisMappings.paraShapeArray)
XCTAssertEqual(officialMappings.forbiddenCharArray, thisMappings.forbiddenCharArray)
// expect(expectedMappings.faceNameArray) == actualMappings.faceNameArray
expect(officialMappings.borderFillArray) == thisMappings.borderFillArray
// expect(officialMappings.charShapeArray) == thisMappings.charShapeArray
expect(officialMappings.paraShapeArray) == thisMappings.paraShapeArray
expect(officialMappings.forbiddenCharArray) == thisMappings.forbiddenCharArray

// XCTAssertEqual(expected.docInfo, actual.docInfo)
// expect(expected.docInfo, actual.docInfo)
}

func testSectionArray() throws {
let (official, this) = try createHwp(#file, "blank-mac2014vp")

XCTAssertEqual(official.sectionArray.count, this.sectionArray.count)
expect(official.sectionArray.count) == this.sectionArray.count

//XCTAssertEqual(official.sectionArray, this.sectionArray)
// expect(official.sectionArray, this.sectionArray)
}
}
52 changes: 23 additions & 29 deletions Tests/CoreHwpTests/Blank/Create2018Tests.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
//
// afds.swift
// HwpKitFrameworkTests
//
// Created by Seungbin Oh on 2020/10/12.
//

import XCTest
import Nimble

/**
doc version : 5.1.0.1.1
Expand All @@ -14,47 +8,47 @@ import XCTest
class Create2018Tests: XCTestCase {

func testCreate() throws {
// XCTAssertEqual(expected, actual)
// expect(expected, actual)
}

func testfileHeader() throws {
let (official, this) = try createHwp(#file, "blank-win2018")

XCTAssertEqual(official.fileHeader, this.fileHeader)
expect(official.fileHeader) == this.fileHeader
}

func testDocInfo() throws {
let (official, this) = try createHwp(#file, "blank-win2018")

XCTAssertEqual(official.docInfo.documentProperties, this.docInfo.documentProperties)
XCTAssertEqual(official.docInfo.compatibleDocument, this.docInfo.compatibleDocument)
expect(official.docInfo.documentProperties) == this.docInfo.documentProperties
expect(official.docInfo.compatibleDocument) == this.docInfo.compatibleDocument

let expectedMappings = official.docInfo.idMappings
let actualMappings = this.docInfo.idMappings

XCTAssertEqual(expectedMappings.faceNameKoreanArray, actualMappings.faceNameKoreanArray)
XCTAssertEqual(expectedMappings.faceNameEnglishArray, actualMappings.faceNameEnglishArray)
XCTAssertEqual(expectedMappings.faceNameChineseArray, actualMappings.faceNameChineseArray)
XCTAssertEqual(expectedMappings.faceNameJapaneseArray, actualMappings.faceNameJapaneseArray)
XCTAssertEqual(expectedMappings.faceNameEtcArray, actualMappings.faceNameEtcArray)
XCTAssertEqual(expectedMappings.faceNameSymbolArray, actualMappings.faceNameSymbolArray)
XCTAssertEqual(expectedMappings.faceNameUserArray, actualMappings.faceNameUserArray)

XCTAssertEqual(expectedMappings.borderFillArray, actualMappings.borderFillArray)
XCTAssertEqual(expectedMappings.charShapeArray, actualMappings.charShapeArray)
XCTAssertEqual(expectedMappings.tabDefArray, actualMappings.tabDefArray)
XCTAssertEqual(expectedMappings.numberingArray, actualMappings.numberingArray)
XCTAssertEqual(expectedMappings.paraShapeArray, actualMappings.paraShapeArray)
XCTAssertEqual(expectedMappings.styleArray, actualMappings.styleArray)

//XCTAssertEqual(expected.docInfo, actual.docInfo)
expect(expectedMappings.faceNameKoreanArray) == actualMappings.faceNameKoreanArray
expect(expectedMappings.faceNameEnglishArray) == actualMappings.faceNameEnglishArray
expect(expectedMappings.faceNameChineseArray) == actualMappings.faceNameChineseArray
expect(expectedMappings.faceNameJapaneseArray) == actualMappings.faceNameJapaneseArray
expect(expectedMappings.faceNameEtcArray) == actualMappings.faceNameEtcArray
expect(expectedMappings.faceNameSymbolArray) == actualMappings.faceNameSymbolArray
expect(expectedMappings.faceNameUserArray) == actualMappings.faceNameUserArray

expect(expectedMappings.borderFillArray) == actualMappings.borderFillArray
expect(expectedMappings.charShapeArray) == actualMappings.charShapeArray
expect(expectedMappings.tabDefArray) == actualMappings.tabDefArray
expect(expectedMappings.numberingArray) == actualMappings.numberingArray
expect(expectedMappings.paraShapeArray) == actualMappings.paraShapeArray
expect(expectedMappings.styleArray) == actualMappings.styleArray

// expect(expected.docInfo, actual.docInfo)
}

func testSectionArray() throws {
let (official, this) = try createHwp(#file, "blank-win2018")

XCTAssertEqual(official.sectionArray.count, this.sectionArray.count)
expect(official.sectionArray.count) == this.sectionArray.count

// XCTAssertEqual(expected.sectionArray, actual.sectionArray)
// expect(expected.sectionArray, actual.sectionArray)
}
}
Loading

0 comments on commit bf2bd0b

Please sign in to comment.